Created
October 21, 2009 09:08
-
-
Save jellybob/214979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def me | |
user_classes = ["User", "Account"] | |
methods = [:email_address, :email, :username, :login] | |
user_classes.each do |class_name| | |
begin | |
klass = class_name.constantize | |
methods.each do |method| | |
return klass.send("find_by_#{method}", "[email protected]") if klass.new.respond_to?(method) | |
end | |
rescue NameError | |
# Move onto the next potential class. | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment