ruby-changes:48824
From: marcandre <ko1@a...>
Date: Thu, 30 Nov 2017 02:47:54 +0900 (JST)
Subject: [ruby-changes:48824] marcandRe: r60940 (trunk): Make Module#attr{accessor|reader|writer|} public [#14132]
marcandre 2017-11-30 02:47:47 +0900 (Thu, 30 Nov 2017) New Revision: 60940 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60940 Log: Make Module#attr{accessor|reader|writer|} public [#14132] Modified files: trunk/NEWS trunk/object.c trunk/test/ruby/test_module.rb Index: NEWS =================================================================== --- NEWS (revision 60939) +++ NEWS (revision 60940) @@ -77,6 +77,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L77 * 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] Index: object.c =================================================================== --- object.c (revision 60939) +++ object.c (revision 60940) @@ -4028,10 +4028,10 @@ InitVM_Object(void) https://github.com/ruby/ruby/blob/trunk/object.c#L4028 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); Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 60939) +++ test/ruby/test_module.rb (revision 60940) @@ -2030,6 +2030,18 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L2030 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/