Class: RubyReactor::Template::DynamicSource
- Defined in:
- lib/ruby_reactor/template/dynamic_source.rb
Instance Attribute Summary collapse
-
#argument_mappings ⇒ Object
readonly
Returns the value of attribute argument_mappings.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
-
#initialize(argument_mappings, &block) ⇒ DynamicSource
constructor
A new instance of DynamicSource.
- #resolve(context) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(argument_mappings, &block) ⇒ DynamicSource
Returns a new instance of DynamicSource.
8 9 10 11 12 |
# File 'lib/ruby_reactor/template/dynamic_source.rb', line 8 def initialize(argument_mappings, &block) super() @block = block @argument_mappings = argument_mappings end |
Instance Attribute Details
#argument_mappings ⇒ Object (readonly)
Returns the value of attribute argument_mappings.
6 7 8 |
# File 'lib/ruby_reactor/template/dynamic_source.rb', line 6 def argument_mappings @argument_mappings end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/ruby_reactor/template/dynamic_source.rb', line 6 def block @block end |
Instance Method Details
#resolve(context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_reactor/template/dynamic_source.rb', line 14 def resolve(context) args = {} @argument_mappings.each do |name, source| # Handle serialized template objects if necessary, similar to MapStep logic # But here we assume source is a Template object that responds to resolve next if source.is_a?(RubyReactor::Template::Element) args[name] = if source.respond_to?(:resolve) source.resolve(context) else source end end @block.call(args, context) end |