Module: ExtraLoop::Hookable
- Included in:
- ExtractionLoop, ScraperBase
- Defined in:
- lib/extraloop/hookable.rb
Defined Under Namespace
Modules: Exceptions
Instance Method Summary collapse
Instance Method Details
#run_hook(hook, arguments) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/extraloop/hookable.rb', line 15 def run_hook(hook, arguments) return unless @hooks.has_key?(hook) @hooks[hook].each do |handler| (@environment || ExtractionEnvironment.new ).run(*arguments, &handler) end end |
#set_hook(hookname, &handler) ⇒ Object Also known as: on
9 10 11 12 13 |
# File 'lib/extraloop/hookable.rb', line 9 def set_hook(hookname, &handler) @hooks ||= {} @hooks[hookname.to_sym] ? @hooks[hookname.to_sym].push(handler) : @hooks[hookname.to_sym] = [handler] self end |