Class: ActionTracker::CollectionProxy
- Inherits:
-
Object
- Object
- ActionTracker::CollectionProxy
show all
- Includes:
- Pagination, Enumerable
- Defined in:
- lib/action_tracker/utils/collection_proxy.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Pagination
#first_page?, #last_page?, #per_page, #size
Constructor Details
#initialize(response, model_name) ⇒ CollectionProxy
Returns a new instance of CollectionProxy.
10
11
12
13
|
# File 'lib/action_tracker/utils/collection_proxy.rb', line 10
def initialize(response, model_name)
@response = response
@model_name = model_name
end
|
Instance Attribute Details
#model_name ⇒ Object
Returns the value of attribute model_name.
8
9
10
|
# File 'lib/action_tracker/utils/collection_proxy.rb', line 8
def model_name
@model_name
end
|
Instance Method Details
#code ⇒ Object
15
16
17
|
# File 'lib/action_tracker/utils/collection_proxy.rb', line 15
def code
@response.code
end
|
#each ⇒ Object
19
20
21
22
23
|
# File 'lib/action_tracker/utils/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/utils/collection_proxy.rb', line 29
def entry_name(options = {})
model_name.singular.pluralize(options[:count])
end
|
#raw_data ⇒ Object
25
26
27
|
# File 'lib/action_tracker/utils/collection_proxy.rb', line 25
def raw_data
@response.dig(model_name.plural) || @response.dig('data')
end
|