Class: Restulicious::Collection
- Inherits:
-
Object
- Object
- Restulicious::Collection
show all
- Includes:
- Enumerable, Attributes
- Defined in:
- lib/restulicious/collection.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Attributes
#initialize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/restulicious/collection.rb', line 20
def method_missing(sym, *args, &block)
if collection_accessor.respond_to?(sym)
collection_accessor.send(sym, *args, &block)
else
super(sym, *args, &block)
end
end
|
Instance Attribute Details
#collection_key ⇒ Object
Returns the value of attribute collection_key.
6
7
8
|
# File 'lib/restulicious/collection.rb', line 6
def collection_key
@collection_key
end
|
Class Method Details
.from_parser(klazz, collection_key, data) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/restulicious/collection.rb', line 8
def self.from_parser(klazz, collection_key, data)
setup_collection_of_items(klazz, collection_key, data)
self.attributes *data.keys
collection = new(data)
collection.collection_key = collection_key
collection
end
|
Instance Method Details
#each(&block) ⇒ Object
16
17
18
|
# File 'lib/restulicious/collection.rb', line 16
def each(&block)
collection_accessor.each(&block)
end
|