Sha256: aa38b4671242865af9cc9a8b15ce0a9f4e73f0b5dd034c9c34622d6e2b65331f
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Samuel module DriverPatches module NetHTTP def self.included(klass) methods_to_wrap = %w(request connect) methods_to_wrap.each do |method| klass.send(:alias_method, "#{method}_without_samuel", method) klass.send(:alias_method, method, "#{method}_with_samuel") end end def request_with_samuel(request, body = nil, &block) Samuel::Diary.record_request(self, request, Time.now) response, exception_raised = nil, false begin response = request_without_samuel(request, body, &block) rescue Exception => response exception_raised = true end Samuel::Diary.record_response(self, request, response, Time.now) raise response if exception_raised response end def connect_with_samuel connect_without_samuel rescue Exception => response fake_request = Object.new def fake_request.path; ""; end def fake_request.method; "CONNECT"; end Samuel::Diary.record_request(self, fake_request, Time.now) Samuel::Diary.record_response(self, fake_request, response, Time.now) raise end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
samuel-0.3.2 | lib/samuel/driver_patches/net_http.rb |
samuel-0.3.1 | lib/samuel/driver_patches/net_http.rb |
samuel-0.3.0 | lib/samuel/driver_patches/net_http.rb |