Class: MOCO::EntityCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/moco/entity_collection.rb

Overview

Provides high-level collection operations for MOCO entities

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/moco/entity_collection.rb', line 9

def client
  @client
end

#entity_class_nameObject (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

#pathObject (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

#allObject



17
18
19
# File 'lib/moco/entity_collection.rb', line 17

def all
  collection.all
end

#countObject



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

#eachObject



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

#firstObject



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