Class: Loom::Pattern::Reference::RunContext
- Inherits:
-
Object
- Object
- Loom::Pattern::Reference::RunContext
- Defined in:
- lib/loom/pattern/reference.rb
Overview
A small class to bind the unbound_method to and provide context in the case of errors.
Instance Method Summary collapse
-
#initialize(unbound_method, definition_ctx) ⇒ RunContext
constructor
A new instance of RunContext.
- #run(shell_api, fact_set) ⇒ Object
Constructor Details
#initialize(unbound_method, definition_ctx) ⇒ RunContext
Returns a new instance of RunContext.
45 46 47 48 |
# File 'lib/loom/pattern/reference.rb', line 45 def initialize(unbound_method, definition_ctx) @bound_method = unbound_method.bind self @definition_ctx = definition_ctx end |
Instance Method Details
#run(shell_api, fact_set) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/loom/pattern/reference.rb', line 50 def run(shell_api, fact_set) before_hooks = @definition_ctx.before_hooks after_hooks = @definition_ctx.after_hooks begin Loom.log.debug1(self) { "before hooks => #{before_hooks}"} before_hooks.each do |hook| Loom.log.debug2(self) { "executing before hook => #{hook}"} self.instance_exec shell_api, fact_set, &hook.block end # This is the entry point into calling patterns. apply_pattern shell_api, fact_set ensure Loom.log.debug1(self) { "after hooks => #{after_hooks}" } after_hooks.each do |hook| Loom.log.debug2(self) { "executing after hook => #{hook}"} self.instance_exec shell_api, fact_set, &hook.block end end end |