summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
blob: 4b0183831170219238ddab3240556e389b4324a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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