From 2857de5f1bf106cc39e628f9f22b3e9ecfcbeb01 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Thu, 23 Jun 2011 17:28:50 -0700 Subject: [PATCH] doc a user method --- app/models/user.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 3d46d7a88..cf66aa4ba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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)