Sha256: 4e4286636bd346e8133853e34c1c8684b6ba86263df2fd2a04fd360556b96ab2
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module Trailblazer::V2_1 module Operation::Wrap module Inject # Returns an Alteration wirings that, when applied, inserts the {ReverseMergeDefaults} task # before the {Wrap::Call} task. This is meant for macros and steps that accept a dependency # injection but need a default parameter to be set if not injected. # @returns ADDS def self.Defaults(default_dependencies) Module.new do extend Activity::Path::Plan() task ReverseMergeDefaults.new( default_dependencies ), id: "ReverseMergeDefaults#{default_dependencies}", before: "task_wrap.call_task" end end # @api private # @returns Task # @param Hash list of key/value that should be set if not already assigned/set before (or injected from the outside). class ReverseMergeDefaults def initialize(defaults) @defaults = defaults end def call((wrap_ctx, original_args), **circuit_options) ctx = original_args[0][0] @defaults.each { |k, v| ctx[k] ||= v } return Activity::Right, [ wrap_ctx, original_args ] end end end # Inject 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/inject.rb |