Sha256: 798c794687cfce6eda55789dfbb3ca01a318fee97808dd6b3baf9c38fbe59e7e

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

module Pragma
  module Operation
    # Finds an existing record, updates it and responds with the decorated record.
    #
    # @author Alessandro Desantis
    class Update < Pragma::Operation::Base
      step Macro::Classes()
      step Macro::Model(:find_by), fail_fast: true
      step Macro::Policy(), fail_fast: true
      step Macro::Contract::Build()
      step Macro::Contract::Validate(), fail_fast: true
      step Macro::Contract::Persist(), fail_fast: true
      step Macro::Decorator()
      step :respond!

      def respond!(options)
        options['result.response'] = Response::Ok.new(entity: options['result.decorator.instance'])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pragma-2.0.0 lib/pragma/operation/update.rb