Module: MonkeyPatch

Defined in:
lib/monkeypatch.rb

Overview

This is the public API to produce new patches.

Once you have a patch, look at Patch and it’s children to see how to use it.

Defined Under Namespace

Modules: IsPatched Classes: AddMethodPatch, ConflictError, MethodPatch, Patch, PatchSet, ReplaceMethodPatch, STDERRLogger

Constant Summary collapse

VERSION =

MonkeyPatch’s version as a string

'0.1.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loaded_patchesObject (readonly)

All defined patches are stored here



199
200
201
# File 'lib/monkeypatch.rb', line 199

def loaded_patches
  @loaded_patches
end

.loggerObject

Here goes the messages, this object should respond_to? :log Default is STDERRLogger



196
197
198
# File 'lib/monkeypatch.rb', line 196

def logger
  @logger
end

Class Method Details

.add_method(method_name, &definition) ⇒ Object

Creates a new patch that adds a method to a class or a module

Returns a Patch (AddMethodPatch)



204
205
206
# File 'lib/monkeypatch.rb', line 204

def add_method(method_name, &definition)
  new_patch AddMethodPatch.send(:new, method_name, &definition)
end

.replace_method(method_name, &definition) ⇒ Object

Creates a new patch that replaces a method of a class or a module

Returns a Patch (ReplaceMethodPatch)



211
212
213
# File 'lib/monkeypatch.rb', line 211

def replace_method(method_name, &definition)
  new_patch ReplaceMethodPatch.send(:new, method_name, &definition)
end