Module: Postmen::CollectionProxy::ClassMethods
- Defined in:
- lib/postmen/collection_proxy.rb
Overview
This module holds all class-level methods
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Settings hash.
Instance Method Summary collapse
-
#get(response) ⇒ Object
Wraps raw JSON response into an model.
-
#key(key = nil) ⇒ Symbol
Sets (if argument is provides) or gets the key where the data is being searched in the API response.
-
#model(model = nil) ⇒ Class
Sets (if argument is provided) or gets the model class name.
Instance Attribute Details
#settings ⇒ Object (readonly)
Settings hash. Used in model/key methods.
12 13 14 |
# File 'lib/postmen/collection_proxy.rb', line 12 def settings @settings end |
Instance Method Details
#get(response) ⇒ Object
Wraps raw JSON response into an model
36 37 38 |
# File 'lib/postmen/collection_proxy.rb', line 36 def get(response) model.new(response[:data]) end |
#key(key = nil) ⇒ Symbol
Sets (if argument is provides) or gets the key where the data is being searched in the API response.
27 28 29 30 |
# File 'lib/postmen/collection_proxy.rb', line 27 def key(key = nil) return settings[:key] unless key settings[:key] = key end |
#model(model = nil) ⇒ Class
Sets (if argument is provided) or gets the model class name
17 18 19 20 |
# File 'lib/postmen/collection_proxy.rb', line 17 def model(model = nil) return settings[:model] unless model settings[:model] = model end |