diff options
author | Azul <azul@leap.se> | 2012-12-13 16:07:31 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-13 17:15:34 +0100 |
commit | 577c3d8149acbd483120847b994582268f93c0b3 (patch) | |
tree | 042c7f3472e38cb9afa70b3a262a7891ffa7ebb5 /users/app/models/email.rb | |
parent | 9762a37ab932ee1a94e973977520c7f4673d78b1 (diff) |
refactor: Email constructor now takes string or hash
This allows us to reuse add_email from email_aliases_attributes=
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r-- | users/app/models/email.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 45101c1..4b01838 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -6,6 +6,11 @@ class Email validates :email, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"} + def initialize(attributes = nil, &block) + attributes = {:email => attributes} if attributes.is_a? String + super(attributes, &block) + end + def to_s email end |