Sha256: 57f87a12bb86b502f037c90c3dbff1846954690362386bfa9d1757d4ea09dcb1

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

require 'trailblazer/operation/model'

module Pragma
  module Operation
    module Macro
      def self.Model(action = nil)
        step = lambda do |input, options|
          Trailblazer::Operation::Pipetree::Step.new(
            Trailblazer::Operation::Model.for(options['model.class'], action),
            'model.class' => options['model.class'],
            'model.action' => action
          ).call(input, options).tap do |result|
            unless result
              options['result.response'] = Pragma::Operation::Response::NotFound.new.decorate_with(
                Pragma::Decorator::Error
              )
            end
          end
        end

        [step, name: 'model.build']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pragma-2.0.0 lib/pragma/operation/macro/model.rb