Class: Truemail::Validate::Smtp::Request
- Inherits:
-
Object
- Object
- Truemail::Validate::Smtp::Request
- Defined in:
- lib/truemail/validate/smtp/request.rb
Defined Under Namespace
Classes: Configuration, Session
Constant Summary collapse
- CONNECTION_TIMEOUT_ERROR =
'connection timed out'
- RESPONSE_TIMEOUT_ERROR =
'server response timeout'
- CONNECTION_DROPPED =
'server dropped connection after response'
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #check_port ⇒ Object
-
#initialize(configuration:, host:, email:, attempts: nil, port_open_status: proc { true }) ⇒ Request
constructor
A new instance of Request.
- #run ⇒ Object
Constructor Details
#initialize(configuration:, host:, email:, attempts: nil, port_open_status: proc { true }) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 19 20 |
# File 'lib/truemail/validate/smtp/request.rb', line 13 def initialize(configuration:, host:, email:, attempts: nil, port_open_status: proc { true }) @configuration = Truemail::Validate::Smtp::Request::Configuration.new(configuration) @response = Truemail::Validate::Smtp::Response.new @host = host @email = email @attempts = attempts @port_open_status = port_open_status end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
11 12 13 |
# File 'lib/truemail/validate/smtp/request.rb', line 11 def configuration @configuration end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/truemail/validate/smtp/request.rb', line 11 def email @email end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/truemail/validate/smtp/request.rb', line 11 def host @host end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/truemail/validate/smtp/request.rb', line 11 def response @response end |
Instance Method Details
#check_port ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/truemail/validate/smtp/request.rb', line 22 def check_port response.port_opened = ::Socket.tcp( host, configuration.smtp_port, connect_timeout: configuration.connection_timeout, &port_open_status ) rescue => error retry if attempts_exist? && error.is_a?(::Errno::ETIMEDOUT) response.port_opened = false end |
#run ⇒ Object
34 35 36 37 38 39 |
# File 'lib/truemail/validate/smtp/request.rb', line 34 def run session.start(verifier_domain, &session_actions) rescue => error retry if attempts_exist? assign_error(attribute: :connection, message: compose_from(error)) end |