summaryrefslogtreecommitdiff
path: root/fake-service/lib/pixelated_service/search/and_match.rb
blob: dfd0f2874fe07c03adec06851417812d942961b8 (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 AndMatch
      attr_reader :data
      def initialize(data = [])
        @data = data
      end
      def <<(node)
        @data << node
      end

      def to_s
        "And(#{@data.join(", ")})"
      end

      def match?(mail)
        self.data.all? { |mm| mm.match?(mail) }
      end

      def match_string?(str)
        self.data.all? { |mm| mm.match_string?(str) }
      end
    end
  end
end