mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make Module#attr{accessor|reader|writer|} public [#14132]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6875e3242f
commit
7298ae9e4b
3 changed files with 19 additions and 4 deletions
3
NEWS
3
NEWS
|
@ -77,6 +77,9 @@ with all sufficient information, see the ChangeLog file or Redmine
|
|||
|
||||
* Kernel#yield_self [Feature #6721]
|
||||
|
||||
* Module
|
||||
* Module#attr, attr_accessor, attr_reader, attr_writer are now public [#14132]
|
||||
|
||||
* Net::HTTP
|
||||
|
||||
* Net::HTTP.new supports no_proxy parameter [Feature #11195]
|
||||
|
|
8
object.c
8
object.c
|
@ -4028,10 +4028,10 @@ InitVM_Object(void)
|
|||
rb_define_method(rb_cModule, "name", rb_mod_name, 0); /* in variable.c */
|
||||
rb_define_method(rb_cModule, "ancestors", rb_mod_ancestors, 0); /* in class.c */
|
||||
|
||||
rb_define_private_method(rb_cModule, "attr", rb_mod_attr, -1);
|
||||
rb_define_private_method(rb_cModule, "attr_reader", rb_mod_attr_reader, -1);
|
||||
rb_define_private_method(rb_cModule, "attr_writer", rb_mod_attr_writer, -1);
|
||||
rb_define_private_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
|
||||
rb_define_method(rb_cModule, "attr", rb_mod_attr, -1);
|
||||
rb_define_method(rb_cModule, "attr_reader", rb_mod_attr_reader, -1);
|
||||
rb_define_method(rb_cModule, "attr_writer", rb_mod_attr_writer, -1);
|
||||
rb_define_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
|
||||
|
||||
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
||||
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
||||
|
|
|
@ -2030,6 +2030,18 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_raise(NameError){ m.instance_eval { remove_const(:__FOO__) } }
|
||||
end
|
||||
|
||||
def test_public_methods
|
||||
public_methods = %i[
|
||||
include
|
||||
prepend
|
||||
attr
|
||||
attr_accessor
|
||||
attr_reader
|
||||
attr_writer
|
||||
]
|
||||
assert_equal public_methods.sort, (Module.public_methods & public_methods).sort
|
||||
end
|
||||
|
||||
def test_private_top_methods
|
||||
assert_top_method_is_private(:include)
|
||||
assert_top_method_is_private(:public)
|
||||
|
|
Loading…
Add table
Reference in a new issue