Sha256: ed55e85bcbe7029ef1817bdf88fe23e4e85d5d69d6aa3543c0987a906733dbc5

Contents?: true

Size: 677 Bytes

Versions: 10

Compression:

Stored size: 677 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

10 entries across 10 versions & 1 rubygems

Version Path
rake-funnel-0.22.2 lib/rake/funnel/support/patch.rb
rake-funnel-0.22.1 lib/rake/funnel/support/patch.rb
rake-funnel-0.22.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.21.2 lib/rake/funnel/support/patch.rb
rake-funnel-0.21.1 lib/rake/funnel/support/patch.rb
rake-funnel-0.21.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.20.2 lib/rake/funnel/support/patch.rb
rake-funnel-0.20.1 lib/rake/funnel/support/patch.rb
rake-funnel-0.20.0 lib/rake/funnel/support/patch.rb
rake-funnel-0.19.0 lib/rake/funnel/support/patch.rb