diff options
author | Azul <azul@leap.se> | 2012-12-13 17:17:30 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-13 17:17:30 +0100 |
commit | a77d5cf5fd2ff6cc335b586477d6d6e58f758591 (patch) | |
tree | 32640ef2457ecce3a08f704f5b5b0ac00a37f9d8 /users/app/models/email.rb | |
parent | 961fe13b784e7f44e55f9cd0a106728c69354a0f (diff) | |
parent | 32db6e2ee3ae449f2fe0f947f9ac4aafde340a9d (diff) |
Merge branch 'master' into develop
Conflicts:
users/test/unit/user_test.rb
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r-- | users/app/models/email.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb new file mode 100644 index 0000000..4b01838 --- /dev/null +++ b/users/app/models/email.rb @@ -0,0 +1,17 @@ +class Email + include CouchRest::Model::Embeddable + + property :email, String + + validates :email, + :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"} + + def initialize(attributes = nil, &block) + attributes = {:email => attributes} if attributes.is_a? String + super(attributes, &block) + end + + def to_s + email + end +end |