composite.rb 693 字节
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
        left.add_bind bind, &block
        right.add_bind bind, &block
        self
      end

25 26 27 28 29 30
      def add_binds(binds, &block)
        left.add_binds(binds, &block)
        right.add_binds(binds, &block)
        self
      end

31 32 33 34
      def value
        [left.value, right.value]
      end

R
Ryuta Kamizono 已提交
35
      private
M
Matthew Draper 已提交
36
        attr_reader :left, :right
37 38 39
    end
  end
end