Class: Exekutor::Internal::Hooks
- Inherits:
-
Object
- Object
- Exekutor::Internal::Hooks
- Includes:
- Callbacks
- Defined in:
- lib/exekutor/internal/hooks.rb
Overview
The internal implementation of the Exekutor hooks
Class Method Summary collapse
-
.on(type, *args) ⇒ Object
Executes an
:on
callback with the given type. -
.run(type, *args, &block) ⇒ Object
Executes the
:before
,:around
, and:after
callbacks with the given type.
Instance Method Summary collapse
- #<<(callback) ⇒ Object
-
#register(callback = nil, &block) ⇒ Object
Registers a hook to be called.
Methods included from Callbacks
Class Method Details
Instance Method Details
#<<(callback) ⇒ Object
34 35 36 |
# File 'lib/exekutor/internal/hooks.rb', line 34 def <<(callback) register callback end |
#register(callback = nil, &block) ⇒ Object
Registers a hook to be called.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/exekutor/internal/hooks.rb', line 18 def register(callback = nil, &block) if callback callback = callback.new if callback.is_a? Class raise "callback must respond to #callbacks" unless callback.respond_to? :callbacks callback.callbacks.each do |type, callbacks| callbacks.each { |cb| add_callback! type, [], cb } end elsif block.arity.zero? instance_eval(&block) else yield self end end |