diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-29 17:47:59 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-29 17:47:59 +0000 |
commit | 0c03a89ecd71ebdc1ea983264424ba5c46f8c4e1 (patch) | |
tree | f8f8bafda5ff2fcbe9eb8c71b51440bc270d01ad | |
parent | 6186e5201afaf517357e748689c7c4fdca8a0f9d (diff) | |
download | ruby-0c03a89ecd71ebdc1ea983264424ba5c46f8c4e1.tar.gz |
Make Module#{define|alias|undef|remove}_method public [#14133]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | proc.c | 2 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 10 | ||||
-rw-r--r-- | vm_method.c | 6 |
4 files changed, 12 insertions, 7 deletions
@@ -79,6 +79,7 @@ with all sufficient information, see the ChangeLog file or Redmine * Module * Module#attr, attr_accessor, attr_reader, attr_writer are now public [#14132] + * Module#define_method, alias_method, undef_method, remove_method are now public [#14133] * Net::HTTP @@ -3164,7 +3164,7 @@ Init_Proc(void) /* Module#*_method */ rb_define_method(rb_cModule, "instance_method", rb_mod_instance_method, 1); rb_define_method(rb_cModule, "public_instance_method", rb_mod_public_instance_method, 1); - rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1); + rb_define_method(rb_cModule, "define_method", rb_mod_define_method, -1); /* Kernel */ rb_define_method(rb_mKernel, "define_singleton_method", rb_obj_define_method, -1); diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 29236644bf..d3e08a1fbb 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -2038,6 +2038,10 @@ class TestModule < Test::Unit::TestCase attr_accessor attr_reader attr_writer + define_method + alias_method + undef_method + remove_method ] assert_equal public_methods.sort, (Module.public_methods & public_methods).sort end @@ -2104,9 +2108,9 @@ class TestModule < Test::Unit::TestCase def test_visibility_by_public_class_method bug8284 = '[ruby-core:54404] [Bug #8284]' - assert_raise(NoMethodError) {Object.define_method} - Module.new.public_class_method(:define_method) - assert_raise(NoMethodError, bug8284) {Object.define_method} + assert_raise(NoMethodError) {Object.remove_const} + Module.new.public_class_method(:remove_const) + assert_raise(NoMethodError, bug8284) {Object.remove_const} end def test_include_module_with_constants_does_not_invalidate_method_cache diff --git a/vm_method.c b/vm_method.c index edbe6038dd..f6024320a3 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2085,9 +2085,9 @@ Init_eval_method(void) rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1); rb_define_method(rb_mKernel, "respond_to_missing?", obj_respond_to_missing, 2); - rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1); - rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1); - rb_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2); + rb_define_method(rb_cModule, "remove_method", rb_mod_remove_method, -1); + rb_define_method(rb_cModule, "undef_method", rb_mod_undef_method, -1); + rb_define_method(rb_cModule, "alias_method", rb_mod_alias_method, 2); rb_define_private_method(rb_cModule, "public", rb_mod_public, -1); rb_define_private_method(rb_cModule, "protected", rb_mod_protected, -1); rb_define_private_method(rb_cModule, "private", rb_mod_private, -1); |