class Occi::Core::Resource
Attributes
links[RW]
Public Class Methods
new(kind=self.kind, mixins=[], attributes={}, actions=[], links=[], location=nil)
click to toggle source
@param [String] kind @param [Array] mixins @param [Occi::Core::Attributes,Hash] attributes @param [Array] links @return [Occi::Core::Resource]
Calls superclass method
Occi::Core::Entity.new
# File lib/occi/core/resource.rb, line 22 def initialize(kind=self.kind, mixins=[], attributes={}, actions=[], links=[], location=nil) super(kind, mixins, attributes, actions, location) @links = Occi::Core::Links.new(links) end
Public Instance Methods
as_json(options={})
click to toggle source
@param [Hash] options @return [Hashie::Mash] link as Hashie::Mash to be parsed into a JSON object
Calls superclass method
Occi::Core::Entity#as_json
# File lib/occi/core/resource.rb, line 74 def as_json(options={}) resource = super resource.links = @links.as_json if @links.any? resource end
link(target, kind=Occi::Core::Link.kind, mixins=[], attributes=Occi::Core::Attributes.new, rel=Occi::Core::Resource.type_identifier)
click to toggle source
# File lib/occi/core/resource.rb, line 43 def link(target, kind=Occi::Core::Link.kind, mixins=[], attributes=Occi::Core::Attributes.new, rel=Occi::Core::Resource.type_identifier) link = kind.entity_type.new link.rel = rel link.attributes = attributes link.id ||= UUIDTools::UUID.random_create.to_s link.target = target link.source = self link.mixins = mixins @links << link link end
model=(model)
click to toggle source
Calls superclass method
Occi::Core::Entity#model=
# File lib/occi/core/resource.rb, line 27 def model=(model) super model @links.model = model end
summary()
click to toggle source
@return [String] summary attribute of the resource
# File lib/occi/core/resource.rb, line 33 def summary self.attributes.occi_.core_.summary end
summary=(summary)
click to toggle source
set summary attribute of resource @param [String] summary
# File lib/occi/core/resource.rb, line 39 def summary=(summary) self.attributes.occi!.core!.summary = summary end
to_header()
click to toggle source
@return [Hash] hash containing the HTTP headers of the text/occi rendering
Calls superclass method
Occi::Core::Entity#to_header
# File lib/occi/core/resource.rb, line 66 def to_header header = super header['Link'] = @links.collect {|link| link.to_string }.join(',') if @links.any? header end
to_text()
click to toggle source
@return [String] text representation
Calls superclass method
Occi::Core::Entity#to_text
# File lib/occi/core/resource.rb, line 59 def to_text text = super @links.each { |link| text << "\n#{link.to_text_link}" } text end