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