Created
November 28, 2008 07:50
-
-
Save ukstudio/29937 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
# クラスオブジェクトを取得 | |
class Foo | |
def class_object | |
self.class.to_s.split(/::/).inject(Object) do |c, name| | |
c.const_get(name) | |
end | |
end | |
end | |
Foo.new.class_object #=> Foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment