Sha256: b56d79671e602def3d60153ec2a16cf1ae3c968e74a309578e474577a6210ada

Contents?: true

Size: 596 Bytes

Versions: 18

Compression:

Stored size: 596 Bytes

Contents

require_dependency 'flexite/action_service'

module Flexite
  class Entry::UpdateService < ActionService
    def call
      if @form.invalid?
        return failure
      end
      record = @form.type.constantize.find(@form.id)
      record.value = @form.value

      if record.changed?
        record.save
      end

      success
    end

    private

    protected

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

    def success
      Result.new(flash: { type: :success, message: 'Entry was updated!' })
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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