Sha256: 19955e75220612fa33a79b5387afcbdcdffb50622803bd203630eb969e3fc3ac
Contents?: true
Size: 876 Bytes
Versions: 24
Compression:
Stored size: 876 Bytes
Contents
module ForestLiana class ResourceUpdater attr_accessor :record attr_accessor :errors def initialize(resource, params) @resource = resource @params = params @errors = nil end def perform begin @record = @resource.find(@params[:id]) if has_strong_parameter @record.update_attributes(resource_params) else @record.update_attributes(resource_params, without_protection: true) end rescue ActiveRecord::StatementInvalid => exception # NOTICE: SQLÂ request cannot be executed properly @errors = [{ detail: exception.cause.error }] end end def resource_params ResourceDeserializer.new(@resource, @params, false).perform end def has_strong_parameter @resource.instance_method(:update_attributes!).arity == 1 end end end
Version data entries
24 entries across 24 versions & 1 rubygems