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.0.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.6 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.5 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.4 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.3 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.6.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.6.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.6.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.5.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.2 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.5.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.4.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-7.0.0.beta.1 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.4.0 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.8 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.7 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.6 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.5 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.4 app/services/forest_liana/belongs_to_updater.rb
forest_liana-6.3.3 app/services/forest_liana/belongs_to_updater.rb