Class: OCCI::Core::Category

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/occi/core/category.rb

Direct Known Subclasses

Action, Kind, Mixin

Instance Method Summary (collapse)

Constructor Details

- (Category) initialize(category = nil, default = nil)



29
30
31
32
# File 'lib/occi/core/category.rb', line 29

def initialize(category=nil, default = nil)
  category.attributes = OCCI::Core::AttributeProperties.new(category.attributes) if category
  super(category, default)
end

Instance Method Details

- (Object) convert_value(val, duping = false)

:nodoc:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/occi/core/category.rb', line 34

def convert_value(val, duping=false) #:nodoc:
  case val
    when self.class
      val.dup
    when ::Hash
      val = val.dup if duping
      self.class.subkey_class.new.merge(val) unless val.kind_of?(Hashie::Mash)
      val
    when Array
      val.collect { |e| convert_value(e) }
    else
      val
  end
end


53
54
55
56
57
58
# File 'lib/occi/core/category.rb', line 53

def related_to?(category_id)
  self.related.each do |category|
    return true if category.type_identifier == category_id || category.related_to?(category_id)
  end if self.related
  false
end

- (Object) type_identifier



49
50
51
# File 'lib/occi/core/category.rb', line 49

def type_identifier
  regular_reader("scheme") + regular_reader("term")
end