Class: ForestLiana::ResourceUpdater

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#recordObject

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

#performObject



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_paramsObject



20
21
22
# File 'app/services/forest_liana/resource_updater.rb', line 20

def resource_params
  ResourceDeserializer.new(@resource, @params[:resource]).perform
end