aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/arel/collectors/substitute_binds.rb
blob: 99d2215aaaf6cece4aeeec76a24b3b87367ab812 (plain) (blame)
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
26
27
28
# frozen_string_literal: true
module Arel
  module Collectors
    class SubstituteBinds
      def initialize(quoter, delegate_collector)
        @quoter = quoter
        @delegate = delegate_collector
      end

      def << str
        delegate << str
        self
      end

      def add_bind bind
        self << quoter.quote(bind)
      end

      def value
        delegate.value
      end

      protected

      attr_reader :quoter, :delegate
    end
  end
end