Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created August 3, 2009 02:33
Show Gist options
  • Select an option

  • Save ELLIOTTCABLE/160334 to your computer and use it in GitHub Desktop.

Select an option

Save ELLIOTTCABLE/160334 to your computer and use it in GitHub Desktop.
module Kernel
def find_const name
name.split('::').inject(Array.new) do |bits, bit|
bits.tap {|b|b << bit}.inject(self) {|o, e| p [o, e]; o.send :const_get, e }
bits
end
end
end
class Foo
class Bar
class Gaz
end
p find_const('Foo::Bar::Gaz')
end
p find_const('Foo::Bar::Gaz')
end
p find_const('Foo::Bar::Gaz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment