Sha256: 09db84bb36b588d73552662b34c987714b4677fa9f7dac41ec28a88290a9232b
Contents?: true
Size: 845 Bytes
Versions: 115
Compression:
Stored size: 845 Bytes
Contents
# frozen_string_literal: true require 'active_support/inflector' require 'eac_ruby_utils/ruby/on_replace_objects/replace_instance_method' module EacRubyUtils module Ruby class OnReplaceObjects class ReplaceInstanceMethod attr_reader :a_module, :method_new_block, :original_method 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 def apply a_module.define_method(method_name, &method_new_block) self end def method_name original_method.name end def restore a_module.define_method(method_name, original_method) self end end end end end
Version data entries
115 entries across 115 versions & 2 rubygems