Sha256: 8bc505141d2276f8d88b00e63dc0ff3ce457467c62dba5f8aac141bbdda21a05

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 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: { status: 400 })
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flexite-0.0.7 app/services/flexite/entry/update_service.rb
flexite-0.0.6 app/services/flexite/entry/update_service.rb
flexite-0.0.5 app/services/flexite/entry/update_service.rb