jellybob (owner)

Revisions

gist: 214979 Download_button fork
public
Public Clone URL: git://gist.github.com/214979.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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