Sha256: cc47ea4b715992c70ec263b9f273d935101cfea9c0f4b8fefab0fee60c3fcbc7

Contents?: true

Size: 676 Bytes

Versions: 18

Compression:

Stored size: 676 Bytes

Contents

module Rake
  module Funnel
    module 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 {}
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.17.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.16.1 lib/rake/funnel/support/patch.rb
rake-funnel-0.16.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.15.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.14.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.13.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.12.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.11.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.10.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.9.1.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.9.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.8.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.7.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.6.1.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.6.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.5.0.pre lib/rake/funnel/support/patch.rb
rake-funnel-0.4.0.pre lib/rake/funnel/support/patch.rb