Skip to content

Instantly share code, notes, and snippets.

@jellybob
Created October 21, 2009 09:08
Show Gist options
  • Save jellybob/214979 to your computer and use it in GitHub Desktop.
Save jellybob/214979 to your computer and use it in GitHub Desktop.
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}", "jon@blankpad.net") 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