Class: HTTPX::Timeout
- Inherits:
-
Object
- Object
- HTTPX::Timeout
- Defined in:
- lib/httpx/timeout.rb
Constant Summary collapse
- CONNECT_TIMEOUT =
60
- OPERATION_TIMEOUT =
60
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#operation_timeout ⇒ Object
readonly
Returns the value of attribute operation_timeout.
-
#total_timeout ⇒ Object
readonly
Returns the value of attribute total_timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, total_timeout: nil, loop_timeout: nil) ⇒ Timeout
constructor
A new instance of Timeout.
- #merge(other) ⇒ Object
Constructor Details
#initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, total_timeout: nil, loop_timeout: nil) ⇒ Timeout
Returns a new instance of Timeout.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/httpx/timeout.rb', line 18 def initialize(connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, total_timeout: nil, loop_timeout: nil) @connect_timeout = connect_timeout @operation_timeout = operation_timeout @total_timeout = total_timeout return unless loop_timeout warn ":loop_timeout is deprecated, use :operation_timeout instead" @operation_timeout = loop_timeout end |
Instance Attribute Details
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
16 17 18 |
# File 'lib/httpx/timeout.rb', line 16 def connect_timeout @connect_timeout end |
#operation_timeout ⇒ Object (readonly)
Returns the value of attribute operation_timeout.
16 17 18 |
# File 'lib/httpx/timeout.rb', line 16 def operation_timeout @operation_timeout end |
#total_timeout ⇒ Object (readonly)
Returns the value of attribute total_timeout.
16 17 18 |
# File 'lib/httpx/timeout.rb', line 16 def total_timeout @total_timeout end |
Class Method Details
.new(opts = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/httpx/timeout.rb', line 10 def self.new(opts = {}) return opts if opts.is_a?(Timeout) super end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/httpx/timeout.rb', line 32 def ==(other) if other.is_a?(Timeout) @connect_timeout == other.instance_variable_get(:@connect_timeout) && @operation_timeout == other.instance_variable_get(:@operation_timeout) && @total_timeout == other.instance_variable_get(:@total_timeout) else super end end |
#merge(other) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/httpx/timeout.rb', line 42 def merge(other) case other when Hash timeout = Timeout.new(other) merge(timeout) when Timeout connect_timeout = other.instance_variable_get(:@connect_timeout) || @connect_timeout operation_timeout = other.instance_variable_get(:@operation_timeout) || @operation_timeout total_timeout = other.instance_variable_get(:@total_timeout) || @total_timeout Timeout.new(connect_timeout: connect_timeout, operation_timeout: operation_timeout, total_timeout: total_timeout) else raise ArgumentError, "can't merge with #{other.class}" end end |