Sha256: a68ff51ddc5e79a30bb9330a8ae468121dfb3fff438971bbc0ea8e2777435e43

Contents?: true

Size: 646 Bytes

Versions: 15

Compression:

Stored size: 646 Bytes

Contents

module Flexite
  class Config
    class UpdateService < ActionService
      def call
        if @form.invalid?
          return failure
        end

        @record = Config.joins(:entry)
          .select("#{Config.table_name}.*, #{Entry.table_name}.id AS entry_id")
          .where(id: @form.id).first
        @record.update_attributes(@form.attributes)
        success
      end

      protected

      def failure
        Result.new(success: false, endpoint: { action: :edit, status: 400 })
      end

      def success
        Result.new(flash: { type: :success, message: 'Config was updated!' }, data: @record)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
flexite-0.0.22 app/services/flexite/config/update_service.rb
flexite-0.0.21 app/services/flexite/config/update_service.rb
flexite-0.0.20 app/services/flexite/config/update_service.rb
flexite-0.0.19 app/services/flexite/config/update_service.rb
flexite-0.0.18 app/services/flexite/config/update_service.rb
flexite-0.0.17 app/services/flexite/config/update_service.rb
flexite-0.0.16 app/services/flexite/config/update_service.rb
flexite-0.0.15 app/services/flexite/config/update_service.rb
flexite-0.0.14 app/services/flexite/config/update_service.rb
flexite-0.0.13 app/services/flexite/config/update_service.rb
flexite-0.0.12 app/services/flexite/config/update_service.rb
flexite-0.0.11 app/services/flexite/config/update_service.rb
flexite-0.0.10 app/services/flexite/config/update_service.rb
flexite-0.0.9 app/services/flexite/config/update_service.rb
flexite-0.0.8 app/services/flexite/config/update_service.rb