Class: ForestLiana::ResourceGetter
- Inherits:
-
BaseGetter
- Object
- BaseGetter
- ForestLiana::ResourceGetter
- Defined in:
- app/services/forest_liana/resource_getter.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
- #includes ⇒ Object
-
#initialize(resource, params) ⇒ ResourceGetter
constructor
A new instance of ResourceGetter.
- #perform ⇒ Object
Methods inherited from BaseGetter
#get_collection, #get_resource
Constructor Details
#initialize(resource, params) ⇒ ResourceGetter
Returns a new instance of ResourceGetter.
5 6 7 8 |
# File 'app/services/forest_liana/resource_getter.rb', line 5 def initialize(resource, params) @resource = resource @params = params end |
Instance Attribute Details
#record ⇒ Object
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
#includes ⇒ Object
14 15 16 17 18 |
# File 'app/services/forest_liana/resource_getter.rb', line 14 def includes SchemaUtils.one_associations(@resource) .select { |association| SchemaUtils.model_included?(association.klass) } .map(&:name) end |
#perform ⇒ Object
10 11 12 |
# File 'app/services/forest_liana/resource_getter.rb', line 10 def perform @record = get_resource().eager_load(includes).find(@params[:id]) end |