summaryrefslogtreecommitdiff
path: root/fake-service/lib/pixelated_service/search/or_match.rb
blob: 2c3e50efe23d72fc7757068839e1424800db83a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module PixelatedService
  class Search
    class OrMatch
      attr_reader :left, :right
      def initialize(left, right)
        @left = left
        @right = right
      end
      def <<(node)
        @right << node
      end
      def to_s
        "Or(#@left, #@right)"
      end

      def match?(mail)
        [@left, @right].any? { |mm| mm.match?(mail) }
      end

      def match_string?(str)
        [@left, @right].any? { |mm| mm.match_string?(str) }
      end
    end
  end
end