Class: ActionTracker::CollectionProxy
- Inherits:
-
Object
- Object
- ActionTracker::CollectionProxy
- Includes:
- Pagination, Enumerable
- Defined in:
- lib/action_tracker/collection_proxy.rb
Instance Attribute Summary collapse
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Instance Method Summary collapse
- #code ⇒ Object
- #each ⇒ Object
- #entry_name(options = {}) ⇒ Object
-
#initialize(response, model_name) ⇒ CollectionProxy
constructor
A new instance of CollectionProxy.
- #raw_data ⇒ Object
Methods included from Pagination
Constructor Details
#initialize(response, model_name) ⇒ CollectionProxy
Returns a new instance of CollectionProxy.
10 11 12 13 |
# File 'lib/action_tracker/collection_proxy.rb', line 10 def initialize(response, model_name) @response = response @model_name = model_name end |
Instance Attribute Details
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
8 9 10 |
# File 'lib/action_tracker/collection_proxy.rb', line 8 def model_name @model_name end |
Instance Method Details
#code ⇒ Object
15 16 17 |
# File 'lib/action_tracker/collection_proxy.rb', line 15 def code @response.code end |
#each ⇒ Object
19 20 21 22 23 |
# File 'lib/action_tracker/collection_proxy.rb', line 19 def each raw_data.each do |record| yield record_klass.new(record) end end |
#entry_name(options = {}) ⇒ Object
29 30 31 |
# File 'lib/action_tracker/collection_proxy.rb', line 29 def entry_name( = {}) model_name.singular.pluralize([:count]) end |
#raw_data ⇒ Object
25 26 27 |
# File 'lib/action_tracker/collection_proxy.rb', line 25 def raw_data @response.dig(model_name.plural) end |