Class: Imap::Backup::Account::Connection::ClientFactory
- Inherits:
-
Object
- Object
- Imap::Backup::Account::Connection::ClientFactory
- Includes:
- RetryOnError
- Defined in:
- lib/imap/backup/account/connection/client_factory.rb
Constant Summary collapse
- LOGIN_RETRY_CLASSES =
[EOFError, Errno::ECONNRESET, SocketError].freeze
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
Instance Method Summary collapse
-
#initialize(account:) ⇒ ClientFactory
constructor
A new instance of ClientFactory.
- #run ⇒ Object
Methods included from RetryOnError
Constructor Details
#initialize(account:) ⇒ ClientFactory
Returns a new instance of ClientFactory.
12 13 14 15 16 |
# File 'lib/imap/backup/account/connection/client_factory.rb', line 12 def initialize(account:) @account = account @provider = nil @server = nil end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
10 11 12 |
# File 'lib/imap/backup/account/connection/client_factory.rb', line 10 def account @account end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/imap/backup/account/connection/client_factory.rb', line 18 def run retry_on_error(errors: LOGIN_RETRY_CLASSES) do = Logger.logger.debug( "Creating IMAP instance: #{server}, options: #{.inspect}" ) client = if provider.is_a?(Email::Provider::AppleMail) Client::AppleMail.new(server, ) else Client::Default.new(server, ) end Logger.logger.debug "Logging in: #{account.username}/#{masked_password}" client.login(account.username, account.password) Logger.logger.debug "Login complete" client end end |