[ruby-core:96347] [Ruby master Feature#8026] Need Module#prepended_modules

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-83258.20191220005135.98b05cc14e5feb63@ruby-lang.org>
Issue #8026 has been updated by mame (Yusuke Endoh).


matz (Yukihiro Matsumoto) wrote:
> But according to the slide, the optional `include_ancestors` is true, but it does mean cherry-picking prepended modules from ancestor list.  I cannot think of any use case of this behavior.

I guess `include_ancestors` here means "modules prepended by prepended modules":

```
module A; end
module B; prepend A; end
module C; prepend B; end

C.prepended_modules(true)  #=> [A, B]
C.prepended_modules(false) #=> [B]
```

So, `include_ancestors` is not a good name; should it be called `include_descendants`?

@marcandre , am I right?

----------------------------------------
Feature #8026: Need Module#prepended_modules
https://bugs.ruby-lang.org/issues/8026#change-83258

* Author: marcandre (Marc-Andre Lafortune)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
We should have a way to get the list of prepended modules of a class or module.

    module Mixin
    end

    module Outer
      prepend Mixin
    end

    Mixin.prepended_modules   #=> []
    Outer.prepended_modules   #=> [Mixin]

See also bug #8025.

---Files--------------------------------
prepended.pdf (99.4 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.