Module: HTTPX::Callbacks
- Included in:
- Connection, HTTPX::Connection::HTTP1, HTTPX::Connection::HTTP2, Plugins::Callbacks::InstanceMethods, Plugins::CircuitBreaker::InstanceMethods, Plugins::Proxy::Socks4::SocksParser, Plugins::Proxy::Socks5::SocksParser, Request, Resolver::Multi, Resolver::Resolver, Response
- Defined in:
- lib/httpx/callbacks.rb
Instance Method Summary collapse
- #callbacks_for?(type) ⇒ Boolean
- #emit(type, *args) ⇒ Object
- #on(type, &action) ⇒ Object
- #once(type, &block) ⇒ Object
Instance Method Details
#callbacks_for?(type) ⇒ Boolean
22 23 24 |
# File 'lib/httpx/callbacks.rb', line 22 def callbacks_for?(type) @callbacks.key?(type) && @callbacks[type].any? end |
#emit(type, *args) ⇒ Object
18 19 20 |
# File 'lib/httpx/callbacks.rb', line 18 def emit(type, *args) callbacks(type).delete_if { |pr| :delete == pr.call(*args) } # rubocop:disable Style/YodaCondition end |
#on(type, &action) ⇒ Object
5 6 7 8 |
# File 'lib/httpx/callbacks.rb', line 5 def on(type, &action) callbacks(type) << action self end |
#once(type, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/httpx/callbacks.rb', line 10 def once(type, &block) on(type) do |*args, &callback| block.call(*args, &callback) :delete end self end |