lib/trailblazer/operation/public_call.rb in trailblazer-operation-0.6.5 vs lib/trailblazer/operation/public_call.rb in trailblazer-operation-0.6.6
- old
+ new
@@ -17,42 +17,57 @@
return call_with_circuit_interface(options, *args) if options.is_a?(Array) # This is kind of a hack that could be well hidden if Ruby had method overloading. Goal is to simplify the call/__call__ thing as we're fading out Operation::call anyway.
call_with_public_interface(options, *args)
end
- def call_with_public_interface(*args)
- ctx = options_for_public_call(*args, flow_options())
+ # Default {@activity} call interface which doesn't accept {circuit_options}
+ #
+ # @param [Array] args => [ctx, flow_options]
+ #
+ # @return [Operation::Railway::Result]
+ #
+ # @private
+ def call_with_public_interface(options, flow_options = {})
+ flow_options = flow_options_for_public_call(flow_options)
+ ctx = options_for_public_call(options, flow_options)
# call the activity.
# This will result in invoking {::call_with_circuit_interface}.
# last_signal, (options, flow_options) = Activity::TaskWrap.invoke(self, [ctx, {}], {})
signal, (ctx, flow_options) = Activity::TaskWrap.invoke(
@activity,
- [ctx, flow_options()],
+ [ctx, flow_options],
exec_context: new
)
# Result is successful if the activity ended with an End event derived from Railway::End::Success.
Operation::Railway::Result(signal, ctx, flow_options)
end
# This interface is used for all nested OPs (and the outer-most, too).
+ #
+ # @param [Array] args - Contains [ctx, flow_options]
+ # @param [Hash] circuit_options - Options to configure activity circuit
+ #
+ # @return [signal, [ctx, flow_options]]
+ #
+ # @private
def call_with_circuit_interface(args, circuit_options)
strategy_call(args, circuit_options) # FastTrack#call
end
def options_for_public_call(*args)
Operation::PublicCall.options_for_public_call(*args)
end
# Compile a Context object to be passed into the Activity::call.
# @private
- def self.options_for_public_call(options, **flow_options)
+ def self.options_for_public_call(options, flow_options = {})
Trailblazer::Context(options, {}, flow_options[:context_options])
end
# @semi=public
- def flow_options
- {}
+ def flow_options_for_public_call(options = {})
+ options
end
end
end