Class: ForestLiana::HasManyGetter
- Inherits:
-
Object
- Object
- ForestLiana::HasManyGetter
- Defined in:
- app/services/forest_liana/has_many_getter.rb
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(resource, association, params) ⇒ HasManyGetter
constructor
A new instance of HasManyGetter.
- #perform ⇒ Object
- #records ⇒ Object
Constructor Details
#initialize(resource, association, params) ⇒ HasManyGetter
Returns a new instance of HasManyGetter.
3 4 5 6 7 |
# File 'app/services/forest_liana/has_many_getter.rb', line 3 def initialize(resource, association, params) @resource = resource @association = association @params = params end |
Instance Method Details
#count ⇒ Object
19 20 21 |
# File 'app/services/forest_liana/has_many_getter.rb', line 19 def count @records.to_a.length end |
#perform ⇒ Object
9 10 11 12 13 |
# File 'app/services/forest_liana/has_many_getter.rb', line 9 def perform @records = @resource.find(@params[:id]).send(@params[:association_name]) @records end |
#records ⇒ Object
15 16 17 |
# File 'app/services/forest_liana/has_many_getter.rb', line 15 def records @records.limit(limit).offset(offset) end |