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.
29 30 31 32 33 |
# File 'lib/trailblazer/activity/task_wrap/inject.rb', line 29 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 |
# 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) Trailblazer.Context(original_ctx.merge()) end output = ->(original_ctx, new_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 |