Class: MonkeyPatch::PatchSet

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

Overview

A collection of patches. Used to collect one or more patches with the #& operator

NOTE: didn’t use the Set class, to not force a dependency

Instance Method Summary collapse

Constructor Details

#initialize(patches) ⇒ PatchSet

:nodoc:



18
19
20
# File 'lib/monkeypatch.rb', line 18

def initialize(patches) #:nodoc:
  @patches = patches.to_a.uniq
end

Instance Method Details

#&(other) ⇒ Object

Aggregates Patch (es) and PatchSet (s)



23
24
25
# File 'lib/monkeypatch.rb', line 23

def &(other)
  PatchSet.new(@patches + other.to_a)
end

#patch_class(klass) ⇒ Object

Delegates to patches TODO: determine what happens if a patch fails



30
31
32
33
34
# File 'lib/monkeypatch.rb', line 30

def patch_class(klass)
  @patches.each do |patch|
    patch.patch_class(klass)
  end
end

#patch_instance(obj) ⇒ Object

Delegates to patches



37
38
39
40
41
# File 'lib/monkeypatch.rb', line 37

def patch_instance(obj)
  for patch in @patches
    patch.patch_instance(obj)
  end
end

#to_aObject



26
# File 'lib/monkeypatch.rb', line 26

def to_a; @patches.dup end