Issue #14132 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Feature #14132: Module#attr{|_reader|_writer} should be public
https://bugs.ruby-lang.org/issues/14132

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Modules and classes can be reopened and changed (unless frozen).

This is used in many meta programming techniques.

Currently, `attr_accessor`, `attr_writer` and `attr_reader` are private, so we need to either do a `class_eval`, reopen the class somehow, or resort to `:send`

As I previously stated in #6539, I feel that the use of `send` should be reserved for incorrect usage of actually private methods that might change of interface or aren't meant to be called this way (e.g. `respond_to_missing?`)

Matz has stated before that "class/module operations should be done in the scope.". Nevertheless, common usage shows that there are many cases where Rubyists prefer using a single line for this, even if it means having to call `send`.

Here are 15k+ examples of `send :attr_accessor` in the wild:
https://github.com/search?utf8=%E2%9C%93&q=language%3Aruby+%22send+%3Aattr_accessor%22&type=Code
15k+ examples of `send :attr_writer` in the wild:
https://github.com/search?utf8=%E2%9C%93&q=language%3Aruby+%22send+%3Aattr_writer%22&type=Code
15k+ examples of `send :attr_reader` in the wild:
https://github.com/search?utf8=%E2%9C%93&q=language%3Aruby+%22send+%3Aattr_reader%22&type=Code

Please make consider making `:attr`, `:attr_accessor`, `:attr_writer` and `:attr_reader` public.



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>