Sha256: 890b980ed04fbf9d79122f15c4cb33ae71b92c451927a0cf918b9ef20ac30b81

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 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)
      step Macro::Policy()
      step Macro::Contract::Build()
      step Macro::Contract::Validate()
      step Macro::Contract::Persist()
      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

2 entries across 2 versions & 1 rubygems

Version Path
pragma-2.1.1 lib/pragma/operation/update.rb
pragma-2.1.0 lib/pragma/operation/update.rb