Class: Occi::Core::Mixin
Direct Known Subclasses
Infrastructure::Network::Ipnetwork, Infrastructure::Networkinterface::Ipnetworkinterface, Infrastructure::Os_tpl, Infrastructure::Resource_tpl
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#entities ⇒ Object
Returns the value of attribute entities.
-
#location ⇒ Object
Returns the value of attribute location.
-
#related ⇒ Object
Returns the value of attribute related.
Attributes inherited from Category
#attributes, #model, #scheme, #term, #title
Instance Method Summary collapse
-
#as_json(options = { }) ⇒ Hashie::Mash
Json representation.
-
#initialize(scheme = 'http://schemas.ogf.org/occi/core#', term = 'mixin', title = nil, attributes = Occi::Core::Attributes.new, related = Occi::Core::Related.new, actions = Occi::Core::Actions.new, location = '') ⇒ Mixin
constructor
A new instance of Mixin.
-
#to_string ⇒ String
Text representation.
Methods inherited from Category
categories, get_class, #inspect, #related_to?, #to_header, #to_s, #to_string_short, #to_text, #type_identifier
Constructor Details
#initialize(scheme = 'http://schemas.ogf.org/occi/core#', term = 'mixin', title = nil, attributes = Occi::Core::Attributes.new, related = Occi::Core::Related.new, actions = Occi::Core::Actions.new, location = '') ⇒ Mixin
Returns a new instance of Mixin.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/occi/core/mixin.rb', line 13 def initialize(scheme='http://schemas.ogf.org/occi/core#', term='mixin', title=nil, attributes=Occi::Core::Attributes.new, =Occi::Core::Related.new, actions=Occi::Core::Actions.new, location='') super(scheme, term, title, attributes) @related = Occi::Core::Related.new() @actions = Occi::Core::Actions.new(actions) @entities = Occi::Core::Entities.new location.blank? ? @location = '/mixins/' + term + '/' : @location = location end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
5 6 7 |
# File 'lib/occi/core/mixin.rb', line 5 def actions @actions end |
#entities ⇒ Object
Returns the value of attribute entities.
5 6 7 |
# File 'lib/occi/core/mixin.rb', line 5 def entities @entities end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/occi/core/mixin.rb', line 5 def location @location end |
#related ⇒ Object
Returns the value of attribute related.
5 6 7 |
# File 'lib/occi/core/mixin.rb', line 5 def @related end |
Instance Method Details
#as_json(options = { }) ⇒ Hashie::Mash
Returns json representation.
34 35 36 37 38 39 40 41 |
# File 'lib/occi/core/mixin.rb', line 34 def as_json(={ }) mixin = Hashie::Mash.new mixin. = @related.join(' ').split(' ') if @related.any? mixin.actions = @actions if @actions.any? mixin.location = @location if @location mixin.merge! super mixin end |
#to_string ⇒ String
Returns text representation.
44 45 46 47 48 49 50 51 |
# File 'lib/occi/core/mixin.rb', line 44 def to_string string = super string << ';rel=' + @related.join(' ').inspect if @related.any? string << ';location=' + self.location.inspect string << ';attributes=' + @attributes.combine.keys.join(' ').inspect if @attributes.any? string << ';actions=' + @actions.join(' ').inspect if @actions.any? string end |