Sha256: db53412e4d68d707bfbb68cbed0408962d5a90f567f41bf9009d21323cd962b7

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

require 'trailblazer/operation/persist'

module Pragma
  module Operation
    module Macro
      module Contract
        def self.Persist(**args)
          step = lambda do |input, options|
            Trailblazer::Operation::Pipetree::Step.new(
              Trailblazer::Operation::Contract::Persist(**args).first
            ).call(input, options).tap do |result|
              unless result
                options['result.response'] = Pragma::Operation::Response::UnprocessableEntity.new(
                  errors: options['model'].errors.messages
                ).decorate_with(Pragma::Decorator::Error)
              end
            end
          end

          [step, name: 'persist.save']
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pragma-2.1.1 lib/pragma/operation/macro/contract/persist.rb
pragma-2.1.0 lib/pragma/operation/macro/contract/persist.rb
pragma-2.0.0 lib/pragma/operation/macro/contract/persist.rb