Class: Mimas::Hooks
- Inherits:
-
Object
- Object
- Mimas::Hooks
- Defined in:
- lib/mimas/hooks.rb
Constant Summary collapse
- POINTS =
[ :before_push, :after_push ]
Class Method Summary collapse
Instance Method Summary collapse
- #[](hook) ⇒ Object
-
#initialize ⇒ Hooks
constructor
A new instance of Hooks.
- #merge(with_hooks) ⇒ Object
Constructor Details
Class Method Details
.run(hooks, args: []) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/mimas/hooks.rb', line 19 def self.run(hooks, args: []) hooks.each do |hook| if hook.arity == args.count hook.call(*args) else hook.call end end end |
Instance Method Details
#[](hook) ⇒ Object
9 10 11 |
# File 'lib/mimas/hooks.rb', line 9 def [](hook) @hooks[hook] end |
#merge(with_hooks) ⇒ Object
13 14 15 16 17 |
# File 'lib/mimas/hooks.rb', line 13 def merge(with_hooks) POINTS.each do |point| @hooks[point].push(*with_hooks[point]) end end |