Class: Imap::Backup::Setup::EmailChanger

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/setup/email_changer.rb

Overview

Asks the user for a new email address

Instance Method Summary collapse

Constructor Details

#initialize(account:, config:) ⇒ EmailChanger

Returns a new instance of EmailChanger.

Parameters:



13
14
15
16
# File 'lib/imap/backup/setup/email_changer.rb', line 13

def initialize(account:, config:)
  @account = 
  @config = config
end

Instance Method Details

#runvoid

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(.username)
  other_accounts = config.accounts.reject { |a| a ==  }
  others = other_accounts.map(&:username)
  if others.include?(username)
    Kernel.puts(
      "There is already an account set up with that email address"
    )
  else
    .username = username
    if .server.nil? || (.server == "")
      default = default_server(username)
      .server = default if default
    end
  end
end