Class: Occi::Core::Entities
- Inherits:
-
Set
- Object
- Set
- Occi::Core::Entities
- Defined in:
- lib/occi/core/entities.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #<<(entity) ⇒ Object
-
#as_json(options = { }) ⇒ Hashie::Mash
Json representation.
- #check ⇒ Object
- #create(*args) ⇒ Object
-
#initialize(entities = []) ⇒ Entities
constructor
A new instance of Entities.
-
#inspect ⇒ String
Json representation.
- #join(separator) ⇒ Object
Constructor Details
#initialize(entities = []) ⇒ Entities
Returns a new instance of Entities.
7 8 9 10 |
# File 'lib/occi/core/entities.rb', line 7 def initialize(entities=[]) entities.to_a.each { |entity| entity.model = @model } if @model super entities end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/occi/core/entities.rb', line 5 def model @model end |
Instance Method Details
#<<(entity) ⇒ Object
32 33 34 35 |
# File 'lib/occi/core/entities.rb', line 32 def <<(entity) entity.model = @model if @model super entity end |
#as_json(options = { }) ⇒ Hashie::Mash
Returns json representation.
39 40 41 |
# File 'lib/occi/core/entities.rb', line 39 def as_json(={ }) self.to_a.as_json end |
#check ⇒ Object
21 22 23 |
# File 'lib/occi/core/entities.rb', line 21 def check each { |entity| entity.check } end |
#create(*args) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/occi/core/entities.rb', line 25 def create(*args) entity = Occi::Core::Entity.new(*args) entity.model = @model if @model self << entity entity end |
#inspect ⇒ String
Returns json representation.
44 45 46 |
# File 'lib/occi/core/entities.rb', line 44 def inspect JSON.pretty_generate(JSON.parse(to_json)) end |
#join(separator) ⇒ Object
12 13 14 |
# File 'lib/occi/core/entities.rb', line 12 def join(separator) self.to_a.join(separator) end |