mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
6186e5201a
commit
0c03a89ecd
4 changed files with 12 additions and 7 deletions
1
NEWS
1
NEWS
|
@ -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
|
||||
|
||||
|
|
2
proc.c
2
proc.c
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue