Created
November 5, 2011 22:08
-
-
Save thinkerbot/1342089 to your computer and use it in GitHub Desktop.
Access included modules on a BasicObject
This file contains hidden or 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 Basic < BasicObject | |
def _included_modules_ | |
class << self | |
SINGLETON_CLASS = self | |
def _included_modules_ | |
SINGLETON_CLASS.included_modules | |
end | |
end | |
_included_modules_ | |
end | |
def extend(mod) | |
mod.__send__(:extend_object, self) | |
end | |
def clone | |
child = ::Basic.new | |
_included_modules_.each {|mod| child.extend mod } | |
child | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment