Sha256: eb06da8b98a3d737add215c6e361b75da83924e63955f581dfe039f8cbec2714

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require 'trailblazer/operation/model'

module Pragma
  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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pragma-2.4.0 lib/pragma/macro/model.rb
pragma-2.3.0 lib/pragma/macro/model.rb
pragma-2.2.0 lib/pragma/macro/model.rb