Module: Samuel::DriverPatches::HTTPClient

Defined in:
lib/samuel/driver_patches/http_client.rb

Defined Under Namespace

Classes: LoggingFilter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/samuel/driver_patches/http_client.rb', line 4

def self.included(klass)
  methods_to_wrap = %w(initialize do_get_block do_get_stream)
  methods_to_wrap.each do |method|
    klass.send(:alias_method, "#{method}_without_samuel", method)
    klass.send(:alias_method, method, "#{method}_with_samuel")
  end
end

Instance Method Details

#do_get_block_with_samuel(req, proxy, conn, &block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/samuel/driver_patches/http_client.rb', line 17

def do_get_block_with_samuel(req, proxy, conn, &block)
  begin
    do_get_block_without_samuel(req, proxy, conn, &block)
  rescue Exception => e
    Samuel::Diary.record_response(self, req, e)
    raise
  end
end

#do_get_stream_with_samuel(req, proxy, conn) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/samuel/driver_patches/http_client.rb', line 26

def do_get_stream_with_samuel(req, proxy, conn)
  begin
    do_get_stream_without_samuel(req, proxy, conn)
  rescue Exception => e
    Samuel::Diary.record_response(self, req, e)
    raise
  end
end

#initialize_with_samuel(*args) ⇒ Object



12
13
14
15
# File 'lib/samuel/driver_patches/http_client.rb', line 12

def initialize_with_samuel(*args)
  initialize_without_samuel(*args)
  @request_filter << LoggingFilter.new(self)
end