summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-08-08 11:54:19 -0700
committerjessib <jessib@riseup.net>2013-08-08 11:54:19 -0700
commitbca39b8f0d44dc31f77a3bfc8a94d452b4c77670 (patch)
treee3ee949bf6e02fc1bbc2ab8e3f247105b962b08e /users/app/models/email.rb
parent31441fc921c3a60bff7c606f1da343fdd62d80d5 (diff)
parentb1065710102193ba11e2a18b5f6506ba1d5b31f9 (diff)
Merge pull request #64 from azul/feature/identity-rewrite
Feature/identity rewrite
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r--users/app/models/email.rb35
1 files changed, 12 insertions, 23 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 6d82f2a..1bcff1c 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -1,33 +1,22 @@
-module Email
- extend ActiveSupport::Concern
+class Email < String
+ include ActiveModel::Validations
- 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
- super(attributes, &block)
- end
-
- def to_s
- email
- end
-
- def ==(other)
- other.is_a?(Email) ? self.email == other.email : self.email == other
- end
+ validates :email,
+ :format => {
+ :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/,
+ :message => "needs to be a valid email address"
+ }
def to_partial_path
"emails/email"
end
def to_param
- email
+ to_s
+ end
+
+ def email
+ self
end
end