Class: EacRubyUtils::Ruby::OnReplaceObjects

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/ruby/on_replace_objects.rb,
lib/eac_ruby_utils/ruby/on_replace_objects/replace_instance_method.rb

Defined Under Namespace

Classes: ReplaceInstanceMethod

Instance Method Summary collapse

Instance Method Details

#on_replacement(&block) ⇒ Object



18
19
20
21
22
23
# File 'lib/eac_ruby_utils/ruby/on_replace_objects.rb', line 18

def on_replacement(&block)
  clear_replacements
  block.call(self)
ensure
  restore_replacements
end

#replace_instance_method(a_module, method_name, &block) ⇒ Object



25
26
27
# File 'lib/eac_ruby_utils/ruby/on_replace_objects.rb', line 25

def replace_instance_method(a_module, method_name, &block)
  add_replacement(__method__, a_module, method_name, &block)
end

#replace_self_method(object, method_name, &block) ⇒ Object



29
30
31
# File 'lib/eac_ruby_utils/ruby/on_replace_objects.rb', line 29

def replace_self_method(object, method_name, &block)
  add_replacement(:replace_instance_method, object.singleton_class, method_name, &block)
end