Sha256: 540fbe9314ceb7871939e4071836983b6470c0a5a28031e387ba4d2195d777ae

Contents?: true

Size: 578 Bytes

Versions: 11

Compression:

Stored size: 578 Bytes

Contents

module Rake::Funnel::Support
  class Patch
    def initialize(context = nil)
      @context = context

      yield self if block_given?
    end

    def setup(&block)
      @setup = block
    end

    def reset(&block)
      @reset = block
    end

    def apply!
      return self if @memo
      @memo = (@setup || noop).call(@context)

      self
    end

    def revert!
      return self unless @memo
      (@reset || noop).call(@memo)
      @memo = nil

      self
    end

    private
    def noop
      Proc.new { }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake-funnel-0.3.2.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.3.1.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.3.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.2.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.1.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.6.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.5.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.4.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.3.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.2.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.0.1.pre lib/rake/funnel/support/patch.rb