Sha256: fe0b1bc29cf868ca8766a0149a429a512354a263752950398d194d8ee4fd68d3

Contents?: true

Size: 396 Bytes

Versions: 1

Compression:

Stored size: 396 Bytes

Contents

module Qo
  class GuardBlockMatcher < Matcher
    IDENTITY = -> v { v }

    def initialize(*array_matchers, **keyword_matchers, &fn)
      @fn = fn || IDENTITY

      super('and', *array_matchers, **keyword_matchers)
    end

    def to_proc
      Proc.new { |match_target|
        next [false, false] unless super[match_target]

        [true, @fn.call(match_target)]
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qo-0.1.10 lib/qo/guard_block_matcher.rb