Module: MethodDisabling::ClassMethods
- Defined in:
- lib/method_disabling.rb
Overview
Provides class-level macros for managing disabled methods.
Instance Method Summary collapse
-
#disable_class_method(method_name, message = nil) ⇒ Object
Disables a class method.
-
#disable_method(method_name, message = nil) ⇒ Object
Disables an instance method.
-
#restore_class_method(method_name) ⇒ Object
Restores a previously disabled class method.
-
#restore_method(method_name) ⇒ Object
Restores a previously disabled instance method.
Instance Method Details
#disable_class_method(method_name, message = nil) ⇒ Object
Disables a class method.
66 67 68 |
# File 'lib/method_disabling.rb', line 66 def disable_class_method(method_name, = nil) (class << self; self; end).disable_method(method_name, ) end |
#disable_method(method_name, message = nil) ⇒ Object
Disables an instance method.
42 43 44 45 |
# File 'lib/method_disabling.rb', line 42 def disable_method(method_name, = nil) disabled_methods[method_name] ||= DisabledMethod.new(self, method_name, ) disabled_methods[method_name].disable! end |
#restore_class_method(method_name) ⇒ Object
Restores a previously disabled class method.
73 74 75 |
# File 'lib/method_disabling.rb', line 73 def restore_class_method(method_name) (class << self; self; end).restore_method(method_name) end |
#restore_method(method_name) ⇒ Object
Restores a previously disabled instance method.
50 51 52 |
# File 'lib/method_disabling.rb', line 50 def restore_method(method_name) disabled_methods[method_name].restore! end |