Skip to content

Instantly share code, notes, and snippets.

@usergenic
Created January 25, 2011 00:47
Show Gist options
  • Save usergenic/794310 to your computer and use it in GitHub Desktop.
Save usergenic/794310 to your computer and use it in GitHub Desktop.
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