class Occi::Core::Resource

Attributes

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/occi4/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/occi4/core/resource.rb, line 74
def as_json(options={})
  resource = super
  resource.links = @links.as_json if @links.any?
  resource
end
model=(model) click to toggle source
Calls superclass method Occi::Core::Entity#model=
# File lib/occi4/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/occi4/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/occi4/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/occi4/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/occi4/core/resource.rb, line 59
def to_text
  text = super
  @links.each { |link| text << "\n#{link.to_text_link}" }
  text
end