summaryrefslogtreecommitdiff
path: root/fake-service/lib/smail/search/or_match.rb
blob: 455923bfde2f5dcf3f53b3d094de4cb0ee3f505e (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 Smail
  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