4 attr_accessor :sendmail, :signature
7 raise ArgumentError, "no name for account" unless h[:name]
8 raise ArgumentError, "no name for email" unless h[:name]
9 super h[:name], h[:email], 0, true
10 @sendmail = h[:sendmail]
11 @signature = h[:signature]
18 attr_accessor :default_account
20 def initialize accounts
24 @default_account = nil
26 add_account accounts[:default], true
27 accounts.each { |k, v| add_account v, false unless k == :default }
29 self.class.i_am_the_instance self
32 def user_accounts; @accounts.keys; end
33 def user_emails; @email_map.keys.select { |e| String === e }; end
35 ## must be called first with the default account. fills in missing
36 ## values from the default account.
37 def add_account hash, default=false
38 raise ArgumentError, "no email specified for account" unless hash[:email]
40 [:name, :sendmail, :signature].each { |k| hash[k] ||= @default_account.send(k) }
42 hash[:alternates] ||= []
45 PersonManager.register a
49 raise ArgumentError, "multiple default accounts" if @default_account
53 ([hash[:email]] + hash[:alternates]).each do |email|
54 next if @email_map.member? email
58 hash[:regexen].each do |re|
59 @regexen[Regexp.new(re)] = a
63 def is_account? p; is_account_email? p.email end
64 def is_account_email? email; !account_for(email).nil? end
66 if(a = @email_map[email])
69 @regexen.argfind { |re, a| re =~ email && a }