Feature #8846

Publicize Module#include

Added by Akira Matsuda 8 months ago. Updated 8 months ago.

[ruby-core:56911]
Status:Closed
Priority:Low
Assignee:-
Category:core
Target version:2.1.0

Description

I propose changing Module#include to a public method.

  • Background
    Module#include is currently a private method.
    However, the method is actually quite often used (particularly by gem library authors) for appending some features from outside of the target module, such as:

    ActiveRecord::Base.send :include, MyPagination

  • Use case
    % cd rails
    % git grep "send[ (]:include," | wc -l
    45

public_include.pdf (37.3 KB) Akira Matsuda, 08/31/2013 02:17 PM


Related issues

Related to ruby-trunk - Feature #6539: public and private for core methods Closed 06/03/2012

Associated revisions

Revision 42824
Added by a_matsuda 8 months ago

  • NEWS: Note about Module#include and prepend scope change

[Feature #8846]

History

#1 Updated by Akira Matsuda 8 months ago

  • File deleted (public_include.pdf)

#2 Updated by Akira Matsuda 8 months ago

#3 Updated by Yukihiro Matsumoto 8 months ago

The basic motivation behind #include (and #prepend) being private is we didn't assume that kind of coding style.
As it turned out, that coding style became popular, I'd accept make them public.

Matz.

#4 Updated by Marc-Andre Lafortune 8 months ago

Great :-)

Taking Rails as an example, I find that the next in line are define_method, remove_const, alias_method and attr_*

As I stated in #6539, I believe these should be public also.

#5 Updated by Akira Matsuda 8 months ago

  • Status changed from Open to Closed

Implemented in r42809.

#6 Updated by Martin Dürst 8 months ago

Hello Marc-Andre,

On 2013/09/01 4:20, marcandre (Marc-Andre Lafortune) wrote:

Issue #8846 has been updated by marcandre (Marc-Andre Lafortune).

Great :-)

Taking Rails as an example, I find that the next in line are define_method, remove_const, alias_method and attr_*

As I stated in #6539, I believe these should be public also.

#6539 is marked closed. Best to open a new issue. Regards, Martin.


Feature #8846: Publicize Module#include
https://bugs.ruby-lang.org/issues/8846#change-41506

Author: matsuda (Akira Matsuda)
Status: Open
Priority: Low
Assignee:
Category: core
Target version: current: 2.1.0

I propose changing Module#include to a public method.

  • Background
    Module#include is currently a private method.
    However, the method is actually quite often used (particularly by gem library authors) for appending some features from outside of the target module, such as:

    ActiveRecord::Base.send :include, MyPagination

  • Use case
    % cd rails
    % git grep "send[ (]:include," | wc -l
    45

Also available in: Atom PDF