Class: Minfra::Cli::Hook::Hooker
- Inherits:
-
Object
- Object
- Minfra::Cli::Hook::Hooker
- Includes:
- Logging
- Defined in:
- lib/minfra/cli/hook.rb
Instance Method Summary collapse
- #call_after_hooks(obj, names) ⇒ Object
- #call_before_hooks(obj, names) ⇒ Object
-
#initialize(klass) ⇒ Hooker
constructor
A new instance of Hooker.
- #register_after(names, block) ⇒ Object
- #register_before(names, block) ⇒ Object
Methods included from Logging
#debug, #deprecated, #error, #exit_error, #info, #warn
Constructor Details
#initialize(klass) ⇒ Hooker
Returns a new instance of Hooker.
62 63 64 65 |
# File 'lib/minfra/cli/hook.rb', line 62 def initialize(klass) @klass = klass @hooks = [] end |
Instance Method Details
#call_after_hooks(obj, names) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/minfra/cli/hook.rb', line 82 def call_after_hooks(obj, names) # debug("Checking after hook #{names}") @hooks.select { |h| h.match?(:after, names) }.each do |h| debug("Hook after: #{names.join(',')}") h.exec(obj) end end |
#call_before_hooks(obj, names) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/minfra/cli/hook.rb', line 75 def call_before_hooks(obj, names) @hooks.select { |h| h.match?(:before, names) }.each do |h| debug("Hook before: #{names.join(',')}") h.exec(obj) end end |