Skip to content

Instantly share code, notes, and snippets.

@LTe
Created August 2, 2012 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LTe/3234492 to your computer and use it in GitHub Desktop.
Save LTe/3234492 to your computer and use it in GitHub Desktop.
class BasicObject
def class
classes = []
::ObjectSpace.each_object(::Class).each do |x|
case self
when x then classes << x
end rescue nil
end
classes.reject! { |k| classes.any? { |c| c < k } }.first
end
end
class S < BasicObject
end
puts S.new.class # => S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment