def initialize h
raise ArgumentError, "no name for account" unless h[:name]
- raise ArgumentError, "no name for email" unless h[:name]
- super h[:name], h[:email], 0, true
+ raise ArgumentError, "no email for account" unless h[:email]
+ super h[:name], h[:email]
@sendmail = h[:sendmail]
@signature = h[:signature]
end
def initialize accounts
@email_map = {}
@accounts = {}
+ @regexen = {}
@default_account = nil
add_account accounts[:default], true
hash[:alternates] ||= []
a = Account.new hash
- PersonManager.register a
@accounts[a] = true
if default
next if @email_map.member? email
@email_map[email] = a
end
+
+ hash[:regexen].each do |re|
+ @regexen[Regexp.new(re)] = a
+ end if hash[:regexen]
end
def is_account? p; is_account_email? p.email end
- def account_for email; @email_map[email] end
def is_account_email? email; !account_for(email).nil? end
+ def account_for email
+ if(a = @email_map[email])
+ a
+ else
+ @regexen.argfind { |re, a| re =~ email && a }
+ end
+ end
end
end