1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/collectors/bind.rb

37 lines
563 B
Ruby
Raw Normal View History

2014-04-09 14:58:44 -04:00
module Arel
module Collectors
class Bind
def initialize
@parts = []
end
def << str
@parts << str
self
end
def add_bind bind
@parts << bind
self
end
def value; @parts; end
def substitute_binds bvs
bvs = bvs.dup
@parts.map do |val|
if Arel::Nodes::BindParam === val
bvs.shift
else
val
end
end
end
2014-04-09 17:31:10 -04:00
def compile bvs
substitute_binds(bvs).join
end
2014-04-09 14:58:44 -04:00
end
end
end