Class: Truemail::Wrapper
- Inherits:
-
Object
- Object
- Truemail::Wrapper
- Defined in:
- lib/truemail/wrapper.rb
Instance Attribute Summary collapse
-
#attempts ⇒ Object
Returns the value of attribute attempts.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(configuration) ⇒ Wrapper
constructor
A new instance of Wrapper.
Constructor Details
#initialize(configuration) ⇒ Wrapper
Returns a new instance of Wrapper.
12 13 14 15 |
# File 'lib/truemail/wrapper.rb', line 12 def initialize(configuration) @attempts = configuration.connection_attempts @timeout = configuration.connection_timeout end |
Instance Attribute Details
#attempts ⇒ Object
Returns the value of attribute attempts.
6 7 8 |
# File 'lib/truemail/wrapper.rb', line 6 def attempts @attempts end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/truemail/wrapper.rb', line 5 def timeout @timeout end |
Class Method Details
.call(configuration:, &block) ⇒ Object
8 9 10 |
# File 'lib/truemail/wrapper.rb', line 8 def self.call(configuration:, &block) new(configuration).call(&block) end |
Instance Method Details
#call(&block) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/truemail/wrapper.rb', line 17 def call(&block) ::Timeout.timeout(timeout, &block) rescue ::Resolv::ResolvError, ::IPAddr::InvalidAddressError false rescue ::Timeout::Error retry unless (self.attempts -= 1).zero? false end |