Class: ForestLiana::ResourceUpdater
- Inherits:
-
Object
- Object
- ForestLiana::ResourceUpdater
- Defined in:
- app/services/forest_liana/resource_updater.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(resource, params) ⇒ ResourceUpdater
constructor
A new instance of ResourceUpdater.
- #perform ⇒ Object
- #resource_params ⇒ Object
Constructor Details
#initialize(resource, params) ⇒ ResourceUpdater
Returns a new instance of ResourceUpdater.
5 6 7 8 |
# File 'app/services/forest_liana/resource_updater.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_updater.rb', line 3 def record @record end |
Instance Method Details
#perform ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/services/forest_liana/resource_updater.rb', line 10 def perform @record = @resource.find(@params[:id]) if Rails::VERSION::MAJOR == 4 @record.update_attributes!(resource_params.permit!) else @record.update_attributes!(resource_params, without_protection: true) end end |
#resource_params ⇒ Object
20 21 22 |
# File 'app/services/forest_liana/resource_updater.rb', line 20 def resource_params ResourceDeserializer.new(@resource, @params[:resource]).perform end |