Sha256: a3bb6c094e15c5555f7da491b62d30a8a1f9c811c5ed74d3d840756361d24ef7

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 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.#{action || 'build'}"]
      end

      module Model
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pragma-2.1.1 lib/pragma/operation/macro/model.rb
pragma-2.1.0 lib/pragma/operation/macro/model.rb