summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-01-17 22:45:39 -0800
committerazul <azul@riseup.net>2013-01-17 22:45:39 -0800
commit168c36b578d675c99aad62a350aa68cc1b6d1316 (patch)
treecd1df0a9a7d3f0a9812b512cfb93db0f79b0421f /users/app/models/email.rb
parent19d563e2e2db98ecc5143229f554df6a09bc457e (diff)
parent27730c7e665ed64e691fdf6dbeebc39c8bfbbc4b (diff)
Merge pull request #18 from leapcode/feature/fixed-email-address
make email address just login@domain.tld
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r--users/app/models/email.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 0745fda..904acb9 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -1,10 +1,13 @@
-class Email
- include CouchRest::Model::Embeddable
+module Email
+ extend ActiveSupport::Concern
- property :email, String
-
- validates :email,
- :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+ included do
+ validates :email,
+ :format => {
+ :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/,
+ :message => "needs to be a valid email address"
+ }
+ end
def initialize(attributes = nil, &block)
attributes = {:email => attributes} if attributes.is_a? String
@@ -16,7 +19,7 @@ class Email
end
def ==(other)
- other.is_a?(String) ? self.email == other : super
+ other.is_a?(Email) ? self.email == other.email : self.email == other
end
def to_param