Class: Retl::Context
- Inherits:
-
Object
- Object
- Retl::Context
- Defined in:
- lib/retl/context.rb
Instance Method Summary collapse
- #_events ⇒ Object
- #execute_step(step, data) ⇒ Object
-
#initialize(path, options = {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(path, options = {}) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/retl/context.rb', line 5 def initialize(path, ={}) path.dependencies.each do |name, dependency| if dependency.nil? && ![name] raise ArgumentError, "This transformation depends on `name`" end self.class.send(:define_method, name) do (dependency && dependency.call()) || [name] end end @_events = EventRouter.new end |
Instance Method Details
#_events ⇒ Object
31 32 33 |
# File 'lib/retl/context.rb', line 31 def _events @_events end |
#execute_step(step, data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/retl/context.rb', line 19 def execute_step(step, data) if step.is_a?(Proc) instance_exec(data, self, &step) else if step.method(:call).arity.abs == 2 step.call(data, self) else step.call(data) end end end |