Module: Typhoeus::Hydra::Callbacks

Included in:
Typhoeus::Hydra
Defined in:
lib/typhoeus/hydra/callbacks.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/typhoeus/hydra/callbacks.rb', line 4

def self.extended(base)
  class << base
    attr_accessor :global_hooks
  end
  base.global_hooks = Hash.new { |h, k| h[k] = [] }
end

Instance Method Details

#after_request_before_on_complete(&block) ⇒ Object



11
12
13
# File 'lib/typhoeus/hydra/callbacks.rb', line 11

def after_request_before_on_complete(&block)
  global_hooks[:after_request_before_on_complete] << block
end

#clear_global_hooksObject



19
20
21
# File 'lib/typhoeus/hydra/callbacks.rb', line 19

def clear_global_hooks
  global_hooks.clear
end

#run_global_hooks_for(name, request) ⇒ Object



15
16
17
# File 'lib/typhoeus/hydra/callbacks.rb', line 15

def run_global_hooks_for(name, request)
  global_hooks[name].each { |hook| hook.call(request) }
end