Class: LittleSniffer::Adapters::NetHttpAdapter
- Inherits:
-
Object
- Object
- LittleSniffer::Adapters::NetHttpAdapter
- Defined in:
- lib/little_sniffer/adapters/net_http_adapter.rb
Instance Method Summary collapse
-
#initialize(handler) ⇒ NetHttpAdapter
constructor
A new instance of NetHttpAdapter.
- #sniff ⇒ Object
Constructor Details
#initialize(handler) ⇒ NetHttpAdapter
9 10 11 |
# File 'lib/little_sniffer/adapters/net_http_adapter.rb', line 9 def initialize(handler) @handler = handler end |
Instance Method Details
#sniff ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/little_sniffer/adapters/net_http_adapter.rb', line 13 def sniff Net::HTTP.define_method(:request_with_sniffer, build_request_with_sniffer(@handler)) Net::HTTP.alias_method(:request_without_sniffer, :request) Net::HTTP.alias_method(:request, :request_with_sniffer) yield ensure Net::HTTP.alias_method(:request, :request_without_sniffer) Net::HTTP.remove_method(:request_with_sniffer) Net::HTTP.remove_method(:request_without_sniffer) end |