Created
January 25, 2011 00:47
-
-
Save usergenic/794310 to your computer and use it in GitHub Desktop.
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 Module | |
# just like include except it makes sure to find all | |
# the modules that have already included self and | |
# update those features with the given module. | |
def include_hard(include_me) | |
include include_me | |
ObjectSpace.each_object(Module) do |some_module| | |
next unless some_module.included_modules.include?(self) | |
next if some_module.included_modules.include?(include_me) | |
some_module.class_eval { include include_me } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment