doc a user method

This commit is contained in:
Raphael Sofaer 2011-06-23 17:28:50 -07:00
parent 18138e1507
commit 2857de5f1b

View file

@ -76,6 +76,9 @@ class User < ActiveRecord::Base
self.language = I18n.locale.to_s if self.language.blank?
end
# This override allows a user to enter either their email address or their username into the username field.
# @return [User] The user that matches the username/email condition.
# @return [nil] if no user matches that condition.
def self.find_for_database_authentication(conditions={})
conditions = conditions.dup
conditions[:username] = conditions[:username].downcase
@ -85,6 +88,8 @@ class User < ActiveRecord::Base
where(conditions).first
end
# @param [Person] person
# @return [Boolean] whether this user can add person as a contact.
def can_add?(person)
return false if self.person == person
return false if self.contact_for(person).present?
@ -92,6 +97,7 @@ class User < ActiveRecord::Base
end
######### Aspects ######################
def move_contact(person, to_aspect, from_aspect)
return true if to_aspect == from_aspect
contact = contact_for(person)