Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created November 28, 2008 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ukstudio/29937 to your computer and use it in GitHub Desktop.
Save ukstudio/29937 to your computer and use it in GitHub Desktop.
# クラスオブジェクトを取得
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