diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/inclusion.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/inclusion.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/inclusion.rb b/activesupport/lib/active_support/core_ext/module/inclusion.rb index efc00d6f28..4f23841645 100644 --- a/activesupport/lib/active_support/core_ext/module/inclusion.rb +++ b/activesupport/lib/active_support/core_ext/module/inclusion.rb @@ -1,4 +1,23 @@ class Module + # Returns the classes in the current ObjectSpace where this module has been + # mixed in according to Module#included_modules. + # + # module M + # end + # + # module N + # include M + # end + # + # class C + # include M + # end + # + # class D < C + # end + # + # p M.included_in_classes # => [C, D] + # def included_in_classes classes = [] ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) } |