Sha256: 5a6a40b1c389a7168908bb66951fedd9c043b502e8111fd21d36dc92c3cfda10

Contents?: true

Size: 784 Bytes

Versions: 3

Compression:

Stored size: 784 Bytes

Contents

module Vanguard
  class Matcher
    class Nullary

      # A matcher that delegates to block
      class Proc < self
        include Equalizer.new(:block)

        # Return block
        #
        # @return [Proc]
        #
        # @api private
        #
        attr_reader :block

        # Test if value matches
        #
        # @return [true]
        #   if block returns non falsy value
        #
        # @return [false]
        #   otherwise
        #
        def matches?(input)
          !!@block.call(input)
        end

        # Initialize object
        #
        # @param [Proc] block
        #
        # @return [undefined]
        #
        # @api private
        #
        def initialize(block)
          @block = block
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vanguard-0.0.5 lib/vanguard/matcher/nullary/proc.rb
vanguard-0.0.4 lib/vanguard/matcher/nullary/proc.rb
vanguard-0.0.3 lib/vanguard/matcher/nullary/proc.rb