From a8ec73a0307924610023525786bb3a9eb8b173e1 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 17 Jan 2013 15:09:58 +0100 Subject: unit tests passing --- users/app/models/email.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'users/app/models/email.rb') 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 -- cgit v1.2.3