Sha256: 55819879385909657d940ad50470f76892c35686809d4d1660212faa7eb2c123
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module Trailblazer::V2_1 class Operation # Use {Callable} if you have an operation or any other callable object that does # _not_ expose an {Activity interface}. For example, {Operation.call} isn't compatible # with activities, hence you need to decorate it using {Callable}. The returned object # exposes an {Activity interface}. # # @param :call [Symbol] Method name to call # @param options [Hash] Hash to merge into {circuit_options}, e.g. {:start_task}. # # @example Create and use a Callable instance. # callable = Trailblazer::V2_1::Operation::Callable( Memo::Create, call: :__call__ ) # callable.( [ctx, {}] ) #=> Activity interface, ::call will invoke Memo::Create.__call__. def self.Callable(*args) Callable.new(*args) end # Subprocess allows to have tasks with a different call interface and start event. # @param activity any object with an {Activity interface} class Callable include Activity::Interface def initialize(activity, call: :call, **options) @activity = activity @options = options @call = call end def call(args, **circuit_options) @activity.public_send(@call, args, circuit_options.merge(@options)) end extend Forwardable # @private def_delegators :@activity, :to_h, :debug def to_s %{#<Trailblazer::V2_1::Activity::Callable activity=#{@activity}>} end end 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/callable.rb |