Module: Trailblazer::Activity::TaskWrap::Inject::Defaults
- Defined in:
- lib/trailblazer/activity/task_wrap/inject.rb
Class Method Summary collapse
-
.defaults_for(defaults, original_ctx) ⇒ Object
go through all defaultable options and default them if appropriate.
- .Extension(defaults) ⇒ Object
Class Method Details
.defaults_for(defaults, original_ctx) ⇒ Object
go through all defaultable options and default them if appropriate.
31 32 33 34 35 |
# File 'lib/trailblazer/activity/task_wrap/inject.rb', line 31 def defaults_for(defaults, original_ctx) Hash[ defaults.collect { |k, v| [k, original_ctx[k] || v] } # FIXME: doesn't allow {false/nil} currently. ] end |
.Extension(defaults) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/trailblazer/activity/task_wrap/inject.rb', line 9 def Extension(defaults) # Returns new ctx. input = ->((original_ctx, ), ) do = defaults_for(defaults, original_ctx) ctx = original_ctx.merge() Trailblazer::Context.for_circuit(ctx, {}, [original_ctx, ], ) # TODO: test if Inject and :context_class work. end output = ->(new_ctx, (original_ctx, ), ) { # FIXME: use Unscope _, mutable_data = new_ctx.decompose # we are only interested in the {mutable_data} part since the disposed part # represents the injected/defaulted data. original_ctx.merge(mutable_data) } VariableMapping::Extension(input, output, id: input) end |