Class: ForestLiana::HasManyGetter

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/has_many_getter.rb

Instance Method Summary collapse

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

#countObject



21
22
23
# File 'app/services/forest_liana/has_many_getter.rb', line 21

def count
  @records.to_a.length
end

#performObject



9
10
11
12
13
14
15
# File 'app/services/forest_liana/has_many_getter.rb', line 9

def perform
  @records = @resource
    .unscoped
    .find(@params[:id])
    .send(@params[:association_name])
  @records = sort_query
end

#recordsObject



17
18
19
# File 'app/services/forest_liana/has_many_getter.rb', line 17

def records
  @records.limit(limit).offset(offset)
end