Class: Imap::Backup::Setup::EmailChanger
- Inherits:
-
Object
- Object
- Imap::Backup::Setup::EmailChanger
- Defined in:
- lib/imap/backup/setup/email_changer.rb
Instance Method Summary collapse
-
#initialize(account:, config:) ⇒ EmailChanger
constructor
A new instance of EmailChanger.
- #run ⇒ Object
Constructor Details
#initialize(account:, config:) ⇒ EmailChanger
Returns a new instance of EmailChanger.
10 11 12 13 |
# File 'lib/imap/backup/setup/email_changer.rb', line 10 def initialize(account:, config:) @account = account @config = config end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/imap/backup/setup/email_changer.rb', line 15 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 |