Sha256: e3f32b83a1aa77d813b6b55cb6e84f5a22f6a2ca8834cb3215c6504e81c15675

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

module Trailblazer::V2_1
  module Operation::Railway
    # Call the user's steps with a differing API (inspired by Maciej Mensfeld) that
    # only receives keyword args. The `options` keyword is the stateful context object
    #
    #   def my_step( params:, ** )
    #   def my_step( params:, options:, ** )
    module Macaroni
      def self.call(user_proc)
        Activity::TaskBuilder::Task.new( Trailblazer::V2_1::Option.build( Macaroni::Option, user_proc ), user_proc )
      end

      class Option < Trailblazer::V2_1::Option
        # The Option#call! method prepares the arguments.
        def self.call!(proc, options, *)
          proc.( **options.to_hash.merge( options: options ) )
        end
      end
    end

    KwSignature = Macaroni
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/operation/railway/macaroni.rb