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-7.6.3 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.6.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.6.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.6.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.5.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.5.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.5 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.4 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.3 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.4.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.3.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.6.3 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.2.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.2.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.2.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.1.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.1 app/services/forest_liana/belongs_to_updater.rb