Class: HasManyEmails::EmailAddress

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/has_many_emails/email_address.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_email(email) ⇒ Object

before_create :set_main after_save :reset_mains


22
23
24
# File 'lib/has_many_emails/email_address.rb', line 22

def self.find_by_email(email)
  super email.downcase
end

Instance Method Details

#==(email) ⇒ Object

TODO А в String кто пропишет такое-же?


31
32
33
# File 'lib/has_many_emails/email_address.rb', line 31

def ==( email )
  email.is_a?( String ) ? to_s==email : super(email)
end

#downcase_emailObject

def set_main

self.is_main = true if self.class.by_user( self.user_id ).empty?
self.email.downcase!

end


40
41
42
# File 'lib/has_many_emails/email_address.rb', line 40

def downcase_email
  self.email = email.downcase if email?
end

#to_sObject


26
27
28
# File 'lib/has_many_emails/email_address.rb', line 26

def to_s
  email
end