summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-01-17 15:09:58 +0100
committerAzul <azul@leap.se>2013-01-17 15:16:53 +0100
commita8ec73a0307924610023525786bb3a9eb8b173e1 (patch)
tree16d937bfea4d18a39aad1eec86edfd4f6467d708 /users/app/models/email.rb
parent7f7ba4f3d72104d67e9ecf839c9688c0580d4063 (diff)
unit tests passing
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