Module: HTTPX::Callbacks

Instance Method Summary collapse

Instance Method Details

#emit(type, *args) ⇒ Object



16
17
18
# File 'lib/httpx/callbacks.rb', line 16

def emit(type, *args)
  callbacks(type).delete_if { |pr| pr[*args] == :delete }
end

#on(type, &action) ⇒ Object



5
6
7
# File 'lib/httpx/callbacks.rb', line 5

def on(type, &action)
  callbacks(type) << action
end

#once(event, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/httpx/callbacks.rb', line 9

def once(event, &block)
  on(event) do |*args, &callback|
    block.call(*args, &callback)
    :delete
  end
end