Class: Imap::Backup::Setup::EmailChanger
- Inherits:
-
Object
- Object
- Imap::Backup::Setup::EmailChanger
- Defined in:
- lib/imap/backup/setup/email_changer.rb
Overview
Asks the user for a new email address
Instance Method Summary collapse
-
#initialize(account:, config:) ⇒ EmailChanger
constructor
A new instance of EmailChanger.
-
#run ⇒ void
Asks the user for an email address, ensuring that the supplied address is not an existing account.
Constructor Details
#initialize(account:, config:) ⇒ EmailChanger
Returns a new instance of EmailChanger.
13 14 15 16 |
# File 'lib/imap/backup/setup/email_changer.rb', line 13 def initialize(account:, config:) @account = account @config = config end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Asks the user for an email address, ensuring that the supplied address is not an existing account
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/imap/backup/setup/email_changer.rb', line 21 def run username = Setup::Asker.email(account.username) other_accounts = config.accounts.reject { |a| a == account } others = other_accounts.map(&:username) if others.include?(username) Kernel.puts( "There is already an account set up with that email address" ) else account.username = username if account.server.nil? || (account.server == "") default = default_server(username) account.server = default if default end end end |