Class: Arel::Collectors::SQLString

Inherits:
PlainString show all
Defined in:
activerecord/lib/arel/collectors/sql_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PlainString

#<<, #value

Constructor Details

#initializeSQLString

Returns a new instance of SQLString.



10
11
12
13
# File 'activerecord/lib/arel/collectors/sql_string.rb', line 10

def initialize(*)
  super
  @bind_index = 1
end

Instance Attribute Details

#preparableObject

Returns the value of attribute preparable



8
9
10
# File 'activerecord/lib/arel/collectors/sql_string.rb', line 8

def preparable
  @preparable
end

Instance Method Details

#add_bind(bind) ⇒ Object



15
16
17
18
19
# File 'activerecord/lib/arel/collectors/sql_string.rb', line 15

def add_bind(bind)
  self << yield(@bind_index)
  @bind_index += 1
  self
end

#add_binds(binds, proc_for_binds = nil, &block) ⇒ Object



21
22
23
24
# File 'activerecord/lib/arel/collectors/sql_string.rb', line 21

def add_binds(binds, proc_for_binds = nil, &block)
  self << (@bind_index...@bind_index += binds.size).map(&block).join(", ")
  self
end