class Module
Stolen from github.com/rails/rails/blob/94ca3e0a571dba0fe41ca18d61634c5f3aa11209/activesupport/lib/active_support/core_ext/class/attribute.rb and github.com/rails/rails/blob/94ca3e0a571dba0fe41ca18d61634c5f3aa11209/activesupport/lib/active_support/core_ext/module/remove_method.rb
Public Instance Methods
redefine_method(method, &block)
click to toggle source
Replaces the existing method definition, if there is one, with the passed block as its body.
# File lib/apple_core/extensions/module.rb, line 23 def redefine_method(method, &block) remove_possible_method(method) define_method(method, &block) end
remove_possible_method(method)
click to toggle source
# File lib/apple_core/extensions/module.rb, line 8 def remove_possible_method(method) return unless method_defined?(method) || private_method_defined?(method) undef_method(method) end
remove_possible_singleton_method(method)
click to toggle source
Removes the named singleton method, if it exists.
# File lib/apple_core/extensions/module.rb, line 15 def remove_possible_singleton_method(method) singleton_class.instance_eval do remove_possible_method(method) end end