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

M
Matthew Draper 已提交
3
module Arel # :nodoc: all
4 5
  module Collectors
    class Composite
6 7
      attr_accessor :preparable

8 9 10 11 12
      def initialize(left, right)
        @left = left
        @right = right
      end

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

M
Matthew Draper 已提交
19
      def add_bind(bind, &block)
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

R
Ryuta Kamizono 已提交
29
      private
M
Matthew Draper 已提交
30
        attr_reader :left, :right
31 32 33
    end
  end
end