Class: EacRubyUtils::Ruby::OnReplaceObjects::ReplaceInstanceMethod
- Defined in:
- lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb
Instance Attribute Summary collapse
-
#a_module ⇒ Object
readonly
Returns the value of attribute a_module.
-
#method_new_block ⇒ Object
readonly
Returns the value of attribute method_new_block.
-
#original_method ⇒ Object
readonly
Returns the value of attribute original_method.
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(a_module, method_name, &method_new_block) ⇒ ReplaceInstanceMethod
constructor
A new instance of ReplaceInstanceMethod.
- #method_name ⇒ Object
- #restore ⇒ Object
Constructor Details
#initialize(a_module, method_name, &method_new_block) ⇒ ReplaceInstanceMethod
Returns a new instance of ReplaceInstanceMethod.
12 13 14 15 16 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 12 def initialize(a_module, method_name, &method_new_block) @a_module = a_module @original_method = a_module.instance_method(method_name) @method_new_block = method_new_block end |
Instance Attribute Details
#a_module ⇒ Object (readonly)
Returns the value of attribute a_module.
10 11 12 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 10 def a_module @a_module end |
#method_new_block ⇒ Object (readonly)
Returns the value of attribute method_new_block.
10 11 12 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 10 def method_new_block @method_new_block end |
#original_method ⇒ Object (readonly)
Returns the value of attribute original_method.
10 11 12 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 10 def original_method @original_method end |
Instance Method Details
#apply ⇒ Object
18 19 20 21 22 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 18 def apply a_module.define_method(method_name, &method_new_block) self end |
#method_name ⇒ Object
24 25 26 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 24 def method_name original_method.name end |
#restore ⇒ Object
28 29 30 31 32 |
# File 'lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb', line 28 def restore a_module.define_method(method_name, original_method) self end |