Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created November 28, 2008 07:50
Show Gist options
  • 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