Class: ForestLiana::ResourceGetter

Inherits:
BaseGetter show all
Defined in:
app/services/forest_liana/resource_getter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseGetter

#get_collection, #get_resource, #includes_for_serialization

Constructor Details

#initialize(resource, params, forest_user) ⇒ ResourceGetter

Returns a new instance of ResourceGetter.



5
6
7
8
9
10
11
12
# File 'app/services/forest_liana/resource_getter.rb', line 5

def initialize(resource, params, forest_user)
  @resource = resource
  @params = params
  @collection_name = ForestLiana.name_for(resource)
  @user = forest_user
  @collection = get_collection(@collection_name)
  compute_includes()
end

Instance Attribute Details

#recordObject

Returns the value of attribute record.



3
4
5
# File 'app/services/forest_liana/resource_getter.rb', line 3

def record
  @record
end

Instance Method Details

#performObject



14
15
16
17
18
# File 'app/services/forest_liana/resource_getter.rb', line 14

def perform
  records = optimize_record_loading(@resource, get_resource())
  scoped_records = ForestLiana::ScopeManager.apply_scopes_on_records(records, @user, @collection_name, @params[:timezone])
  @record = scoped_records.find(@params[:id])
end