Class: MonkeyPatch::MethodPatch

Inherits:
Patch
  • Object
show all
Defined in:
lib/monkeypatch.rb

Direct Known Subclasses

AddMethodPatch, ReplaceMethodPatch

Instance Attribute Summary collapse

Attributes inherited from Patch

#from

Instance Method Summary collapse

Methods inherited from Patch

#&, #add_condition, #patch_class, #patch_instance, #to_a

Constructor Details

#initialize(method_name, &patch_def) ⇒ MethodPatch

:nodoc:



138
139
140
141
142
143
144
# File 'lib/monkeypatch.rb', line 138

def initialize(method_name, &patch_def) #:nodoc:
  super(&patch_def)
  @method_name = method_name.to_s
  unless Module.new(&patch_def).instance_methods(true) == [@method_name]
    raise ArgumentError, "&patch_def does not define the specified method"
  end 
end

Instance Attribute Details

#method_nameObject (readonly)

The name of the method to be patched



137
138
139
# File 'lib/monkeypatch.rb', line 137

def method_name
  @method_name
end