Class: Occi::Core::Entities

Inherits:
Set
  • Object
show all
Includes:
Helpers::Inspect
Defined in:
lib/occi/core/entities.rb

Direct Known Subclasses

Links, Resources

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Inspect

#inspect

Constructor Details

#initialize(entities = []) ⇒ Entities

Returns a new instance of Entities


9
10
11
12
# File 'lib/occi/core/entities.rb', line 9

def initialize(entities=[])
  entities.to_a.each { |entity| entity.model = @model } if @model
  super entities
end

Instance Attribute Details

#modelObject

Returns the value of attribute model


7
8
9
# File 'lib/occi/core/entities.rb', line 7

def model
  @model
end

Instance Method Details

#<<(entity) ⇒ Object


34
35
36
37
# File 'lib/occi/core/entities.rb', line 34

def <<(entity)
  entity.model = @model if @model
  super entity
end

#as_json(options = { }) ⇒ Hashie::Mash

Returns json representation

Parameters:

  • options (Hash) (defaults to: { })

Returns:

  • (Hashie::Mash)

    json representation


41
42
43
# File 'lib/occi/core/entities.rb', line 41

def as_json(options={ })
  self.to_a.as_json
end

#checkObject


23
24
25
# File 'lib/occi/core/entities.rb', line 23

def check
  each { |entity| entity.check }
end

#create(*args) ⇒ Object


27
28
29
30
31
32
# File 'lib/occi/core/entities.rb', line 27

def create(*args)
  entity = Occi::Core::Entity.new(*args)
  entity.model = @model if @model
  self << entity
  entity
end

#join(separator) ⇒ Object


14
15
16
# File 'lib/occi/core/entities.rb', line 14

def join(separator)
  self.to_a.join(separator)
end