Sha256: 80155913fb33cba0f8741e62884d8d53832097d0bf6c3374c94627882d80890e
Contents?: true
Size: 878 Bytes
Versions: 2
Compression:
Stored size: 878 Bytes
Contents
# frozen_string_literal: true require "ostruct" module Fear module Extractor class Matcher < OpenStruct # Combine two matchers, so both should pass class And < Matcher def initialize(matcher1, matcher2) @matcher1 = matcher1 @matcher2 = matcher2 end attr_reader :matcher1, :matcher2 def defined_at?(arg) matcher1.defined_at?(arg) && matcher2.defined_at?(arg) end def bindings(arg) matcher1.bindings(arg).merge(matcher2.bindings(arg)) end def failure_reason(arg) if matcher1.defined_at?(arg) if matcher2.defined_at?(arg) Fear.none else matcher2.failure_reason(arg) end else matcher1.failure_reason(arg) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fear-1.2.0 | lib/fear/extractor/matcher/and.rb |
fear-1.1.0 | lib/fear/extractor/matcher/and.rb |