composite.rb 527 字节
Newer Older
1 2
# frozen_string_literal: true

M
Matthew Draper 已提交
3
module Arel # :nodoc: all
4 5 6 7 8 9 10
  module Collectors
    class Composite
      def initialize(left, right)
        @left = left
        @right = right
      end

M
Matthew Draper 已提交
11
      def <<(str)
12 13 14 15 16
        left << str
        right << str
        self
      end

M
Matthew Draper 已提交
17
      def add_bind(bind, &block)
18 19 20 21 22 23 24 25 26 27 28
        left.add_bind bind, &block
        right.add_bind bind, &block
        self
      end

      def value
        [left.value, right.value]
      end

      protected

M
Matthew Draper 已提交
29
        attr_reader :left, :right
30 31 32
    end
  end
end