remove_possible_method 不删除模块的方法

问题描述 投票:0回答:0

My_module.methods
回报:

[:local_constants, :module_exec, :class_exec, :module_eval, :class_eval,
:included_modules, :include?, :name, :ancestors, :instance_methods, :public_instance_methods, :protected_instance_methods, 
:private_instance_methods, :constants, :const_get, :const_set, 
:const_defined?, :class_variables, :remove_class_variable, 
:class_variable_get, :class_variable_set, :class_variable_defined?,
:public_constant, :private_constant, :deprecate_constant, :singleton_class?,
:public_method_defined?, :method_defined?, :protected_method_defined?, 
:private_method_defined?, :public_class_method, :private_class_method, :<, 
:>, :alias_method_chain, :alias_attribute,   .......]

My_module.instance_methods
回报

[:test_module, :test_func, ....]

所以当我做

My_module.remove_possible_method :test_module
它不会删除它。

如果我试着打电话给

My_module.test_module
它抛出这个错误:

Exception: undefined method `get_portal_redis_key' for #<Module:0x00007fea9b946>
ruby-on-rails ruby-on-rails-3
© www.soinside.com 2019 - 2024. All rights reserved.