class HTTPX::Timeout

  1. lib/httpx/timeout.rb
Superclass: Object

Methods

Public Class

  1. new
  2. new

Public Instance

  1. ==
  2. connect_timeout
  3. merge
  4. operation_timeout
  5. total_timeout

Constants

CONNECT_TIMEOUT = 60  
OPERATION_TIMEOUT = 60  

Public Class methods

new (opts = {})
[show source]
   # File lib/httpx/timeout.rb
10 def self.new(opts = {})
11   return opts if opts.is_a?(Timeout)
12 
13   super
14 end
new (connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, total_timeout: nil, loop_timeout: nil)
[show source]
   # File lib/httpx/timeout.rb
18 def initialize(connect_timeout: CONNECT_TIMEOUT,
19                operation_timeout: OPERATION_TIMEOUT,
20                total_timeout: nil,
21                loop_timeout: nil)
22   @connect_timeout = connect_timeout
23   @operation_timeout = operation_timeout
24   @total_timeout = total_timeout
25 
26   return unless loop_timeout
27 
28   warn ":loop_timeout is deprecated, use :operation_timeout instead"
29   @operation_timeout = loop_timeout
30 end

Public Instance methods

== (other)
[show source]
   # File lib/httpx/timeout.rb
32 def ==(other)
33   if other.is_a?(Timeout)
34     @connect_timeout == other.instance_variable_get(:@connect_timeout) &&
35       @operation_timeout == other.instance_variable_get(:@operation_timeout) &&
36       @total_timeout == other.instance_variable_get(:@total_timeout)
37   else
38     super
39   end
40 end
merge (other)
[show source]
   # File lib/httpx/timeout.rb
42 def merge(other)
43   case other
44   when Hash
45     timeout = Timeout.new(other)
46     merge(timeout)
47   when Timeout
48     connect_timeout = other.instance_variable_get(:@connect_timeout) || @connect_timeout
49     operation_timeout = other.instance_variable_get(:@operation_timeout) || @operation_timeout
50     total_timeout = other.instance_variable_get(:@total_timeout) || @total_timeout
51     Timeout.new(connect_timeout: connect_timeout,
52                 operation_timeout: operation_timeout,
53                 total_timeout: total_timeout)
54   else
55     raise ArgumentError, "can't merge with #{other.class}"
56   end
57 end