Sha256: a0e4038439edeca3bbef626a32fdd95c20311ad1333ecbdef7b0f7bd9859d139

Contents?: true

Size: 715 Bytes

Versions: 277

Compression:

Stored size: 715 Bytes

Contents

module ForestLiana
  class BelongsToUpdater
    attr_accessor :errors

    def initialize(resource, association, params)
      @resource = resource
      @association = association
      @params = params
      @data = params['data']
      @errors = nil
    end

    def perform
      begin
        @record = @resource.find(@params[:id])
        new_value = @association.klass.find(@data[:id]) if @data && @data[:id]
        @record.send("#{@association.name}=", new_value)

        @record.save
      rescue ActiveRecord::SerializationTypeMismatch => exception
        @errors = [{ detail: exception.message }]
      rescue => exception
        @errors = [{ detail: exception.message }]
      end
    end
  end
end

Version data entries

277 entries across 277 versions & 1 rubygems

Version Path
forest_liana-8.0.17 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.8.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.16 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.15 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.14 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.13 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.12 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.11 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.10 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.9 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.8 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.7 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.6 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.5 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.4 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.3 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-8.0.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.8.1 app/services/forest_liana/belongs_to_updater.rb