module Runbook::Hooks::Invoker
Public Instance Methods
_execute_after_hooks(executor, object, *args)
click to toggle source
# File lib/runbook/hooks.rb, line 81 def _execute_after_hooks(executor, object, *args) executor.hooks_for(:after, object.class).each do |hook| executor.instance_exec(object, *args, &hook[:block]) end end
_execute_around_hooks(executor, object, *args) { || ... }
click to toggle source
# File lib/runbook/hooks.rb, line 66 def _execute_around_hooks(executor, object, *args) executor.hooks_for(:around, object.class).reverse.reduce( -> (object, *args) { yield } ) do |inner_method, hook| -> (object, *args) { inner_block = Proc.new do |object, *args| inner_method.call(object, *args) end executor.instance_exec(object, *args, inner_block, &hook[:block]) } end.call(object, *args) end
_execute_before_hooks(executor, object, *args)
click to toggle source
# File lib/runbook/hooks.rb, line 60 def _execute_before_hooks(executor, object, *args) executor.hooks_for(:before, object.class).each do |hook| executor.instance_exec(object, *args, &hook[:block]) end end
invoke_with_hooks(executor, object, *args, &block)
click to toggle source
# File lib/runbook/hooks.rb, line 33 def invoke_with_hooks(executor, object, *args, &block) skip_before = skip_around = skip_after = false if executor <= Runbook::Run if executor.should_skip?(args[0]) if executor.start_at_is_substep?(object, args[0]) skip_before = skip_around = true else skip_before = skip_around = skip_after = true end end end unless skip_before _execute_before_hooks(executor, object, *args) end if skip_around block.call else _execute_around_hooks(executor, object, *args, &block) end unless skip_after _execute_after_hooks(executor, object, *args) end end