Skip to content

Commit

Permalink
Refactor. [#18]
Browse files Browse the repository at this point in the history
  • Loading branch information
marnen committed Mar 24, 2009
1 parent 21e3b4d commit f767868
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/user.rb
Expand Up @@ -58,7 +58,9 @@ def coords
# Compares users by last name, first name, and e-mail address in that order.
# ['Smith', 'John', 'jsmith1@aol.com'] < ['Smith', 'John', 'jsmith2@aol.com']
def <=>(other)
[self.lastname, self.firstname, self.email] <=> [other.lastname, other.firstname, other.email]
attrs = [:lastname, :firstname, :email]
attrs.collect{|a| self.read_attribute a} <=> attrs.collect{|a| other.read_attribute a}
#[self.lastname, self.firstname, self.email] <=> [other.lastname, other.firstname, other.email]
end

# Returns the user's name as a string. Order can be :first_last (default) or :last_first. E-mail address will be returned if no name is specified.
Expand Down

0 comments on commit f767868

Please sign in to comment.