Class: MOCO::EntityCollection
- Inherits:
-
Object
- Object
- MOCO::EntityCollection
- Includes:
- Enumerable
- Defined in:
- lib/moco/entity_collection.rb
Overview
Provides high-level collection operations for MOCO entities
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#entity_class_name ⇒ Object
readonly
Returns the value of attribute entity_class_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #all ⇒ Object
- #count ⇒ Object
- #create(attributes) ⇒ Object
- #delete(id) ⇒ Object
- #each ⇒ Object
- #find(id) ⇒ Object
- #first ⇒ Object
-
#initialize(client, path, entity_class_name) ⇒ EntityCollection
constructor
A new instance of EntityCollection.
- #update(id, attributes) ⇒ Object
- #where(filters = {}) ⇒ Object
Constructor Details
#initialize(client, path, entity_class_name) ⇒ EntityCollection
Returns a new instance of EntityCollection.
11 12 13 14 15 |
# File 'lib/moco/entity_collection.rb', line 11 def initialize(client, path, entity_class_name) @client = client @path = path @entity_class_name = entity_class_name end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/moco/entity_collection.rb', line 9 def client @client end |
#entity_class_name ⇒ Object (readonly)
Returns the value of attribute entity_class_name.
9 10 11 |
# File 'lib/moco/entity_collection.rb', line 9 def entity_class_name @entity_class_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/moco/entity_collection.rb', line 9 def path @path end |
Instance Method Details
#all ⇒ Object
17 18 19 |
# File 'lib/moco/entity_collection.rb', line 17 def all collection.all end |
#count ⇒ Object
41 42 43 |
# File 'lib/moco/entity_collection.rb', line 41 def count all.count end |
#create(attributes) ⇒ Object
29 30 31 |
# File 'lib/moco/entity_collection.rb', line 29 def create(attributes) collection.create(attributes) end |
#delete(id) ⇒ Object
49 50 51 |
# File 'lib/moco/entity_collection.rb', line 49 def delete(id) collection.delete(id) end |
#each ⇒ Object
33 34 35 |
# File 'lib/moco/entity_collection.rb', line 33 def each(&) collection.each(&) end |
#find(id) ⇒ Object
21 22 23 |
# File 'lib/moco/entity_collection.rb', line 21 def find(id) collection.find(id) end |
#first ⇒ Object
37 38 39 |
# File 'lib/moco/entity_collection.rb', line 37 def first all.first end |
#update(id, attributes) ⇒ Object
45 46 47 |
# File 'lib/moco/entity_collection.rb', line 45 def update(id, attributes) collection.update(id, attributes) end |
#where(filters = {}) ⇒ Object
25 26 27 |
# File 'lib/moco/entity_collection.rb', line 25 def where(filters = {}) collection.where(filters) end |