Project

General

Profile

Bug #8841

Module#included_modules and prepended modules

Added by marcandre (Marc-Andre Lafortune) over 6 years ago. Updated 9 days ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
r42735
Backport:
[ruby-core:56898]
Tags:

Description

The documentation for Module#included_modules currently states "Returns the list of modules included in +mod+."

This was never perfectly accurate, as the list also contains modules included in +mod+'s ancestors.

It now also includes prepended modules.

This is consistent with include? that returns true for prepended modules, but not quite consistent with included that does not get called for prepended modules.

Matz, could you confirm that current behavior is what you want?

If so, we should fix the documentation of include? and included_modules.


Related issues

Related to Backport200 - Backport #8025: Module#included_modules includes classesClosed03/06/2013Actions
Related to Ruby master - Feature #8026: Need Module#prepended_modulesFeedbackActions

Associated revisions

Revision 8ab11096
Added by Marc-Andre Lafortune 9 days ago

Clarify documentation for Module#included_modules and Module#included?

[DOC] [ci skip] [Bug #8841]

History

#1

Updated by naruse (Yui NARUSE) about 2 years ago

  • Target version deleted (2.6)

Updated by mame (Yusuke Endoh) about 1 month ago

Summary:

  • Module#include? and Module#included_modules regard prepended modules as included (not well documented)
  • Module#included is not called when the module is prepended

Is this right?

Updated by byroot (Jean Boussier) about 1 month ago

Module#included is not called when the module is prepended

I think that's fine, because it calls Module#prepended.

Module#include? and Module#included_modules regard prepended modules as included (not well documented)

That yes:

class Base
end

module A
end

module B
end

Base.prepend(A)
Base.include(B)

p Base.included_modules

outputs:

[A, B, Kernel]

Updated by matz (Yukihiro Matsumoto) 9 days ago

  • Status changed from Open to Closed

This intentional.

Matz.

Updated by marcandre (Marc-Andre Lafortune) 9 days ago

Thank you.

I clarified the documentation to reflect this.

Also available in: Atom PDF