diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-29 17:47:47 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-29 17:47:47 +0000 |
commit | 7298ae9e4bcef612009d3aa0caba4fde3276a7f3 (patch) | |
tree | e9c5df29cc07c9c4b8de3b4493b6651636e9828f | |
parent | 6875e3242f967995f89cf38fae05f4744be1f66f (diff) | |
download | ruby-7298ae9e4bcef612009d3aa0caba4fde3276a7f3.tar.gz |
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
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | object.c | 8 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 12 |
3 files changed, 19 insertions, 4 deletions
@@ -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] @@ -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); diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index d1c5d53822..29236644bf 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -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) |