@param [String] scheme @param [String] term @param [String] title @param [Occi::Core::Attributes,Hash,NilClass] attributes @param [Occi::Core::Categories,Hash,NilClass] depends @param [Occi::Core::Actions,Hash,NilClass] actions @param [String] location @param [Occi::Core::Kinds, NilClass] applies
# File lib/occi4/core/mixin.rb, line 15 def initialize(scheme='http://schemas.ogf.org/occi/core#', term='mixin', title=nil, attributes=Occi::Core::Attributes.new, depends=Occi::Core::Dependencies.new, actions=Occi::Core::Actions.new, location='', applies=Occi::Core::Kinds.new) super(scheme, term, title, attributes) @depends = Occi::Core::Dependencies.new depends @actions = Occi::Core::Actions.new actions @entities = Occi::Core::Entities.new @location = location.blank? ? "/mixin/#{term}/" : URI.parse(location).path @applies = Occi::Core::Kinds.new applies end
@param [Hash] options @return [Hashie::Mash] json representation
# File lib/occi4/core/mixin.rb, line 58 def as_json(options={}) mixin = Hashie::Mash.new mixin.depends = self.depends.to_a.collect { |m| m.type_identifier } if self.depends.any? mixin.applies = self.applies.to_a.collect { |m| m.type_identifier } if self.applies.any? mixin.related = self.related.to_a.collect { |m| m.type_identifier } if self.related.any? mixin.actions = self.actions if self.actions.any? mixin.location = self.location if self.location mixin.merge! super mixin end
# File lib/occi4/core/mixin.rb, line 48 def location @location ? @location.clone : nil end
set location attribute of kind @param [String] location
# File lib/occi4/core/mixin.rb, line 42 def location=(location) location = URI.parse(location).path if location raise "Mixin locations must end with a slash!" unless location.blank? || location =~ /^\/\S+\/$/ @location = location end
@return [String] text representation
# File lib/occi4/core/mixin.rb, line 70 def to_string string = super string << ";rel=#{self.related.join(' ').inspect}" if self.related.any? string << ";location=#{self.location.inspect}" string << self.attributes.to_string_short string << ";actions=#{self.actions.join(' ').inspect}" if self.actions.any? string end