module HTTPX::Callbacks

  1. lib/httpx/callbacks.rb

Methods

Public Instance

  1. emit
  2. on
  3. once

Protected Instance

  1. callbacks

Public Instance methods

emit (type, *args)
[show source]
   # File lib/httpx/callbacks.rb
16 def emit(type, *args)
17   callbacks(type).delete_if { |pr| pr[*args] == :delete }
18 end
on (type, &action)
[show source]
  # File lib/httpx/callbacks.rb
5 def on(type, &action)
6   callbacks(type) << action
7 end
once (event, &block)
[show source]
   # File lib/httpx/callbacks.rb
 9 def once(event, &block)
10   on(event) do |*args, &callback|
11     block.call(*args, &callback)
12     :delete
13   end
14 end

Protected Instance methods

callbacks (type = nil)
[show source]
   # File lib/httpx/callbacks.rb
22 def callbacks(type = nil)
23   return @callbacks unless type
24 
25   @callbacks ||= Hash.new { |h, k| h[k] = [] }
26   @callbacks[type]
27 end