summaryrefslogtreecommitdiff
path: root/users/app/models/user.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-12-13 16:07:31 +0100
committerAzul <azul@leap.se>2012-12-13 17:15:34 +0100
commit577c3d8149acbd483120847b994582268f93c0b3 (patch)
tree042c7f3472e38cb9afa70b3a262a7891ffa7ebb5 /users/app/models/user.rb
parent9762a37ab932ee1a94e973977520c7f4673d78b1 (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/user.rb')
-rw-r--r--users/app/models/user.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 7c9002b..b531dfd 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -113,16 +113,15 @@ class User < CouchRest::Model::Base
end
def add_email(email)
- email = LocalEmail.new({:email => email}) unless email.is_a? Email
+ email = LocalEmail.new(email) unless email.is_a? Email
email_aliases << email
end
# this currently only adds the first email address submitted.
# All the ui needs for now.
def email_aliases_attributes=(attrs)
- if attrs
- email_alias = LocalEmail.new(attrs.values.first)
- email_aliases << email_alias
+ if attrs && attrs.values.first
+ add_email attrs.values.first
end
end