aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/collectors/bind.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/collectors/bind.rb')
-rw-r--r--lib/arel/collectors/bind.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/arel/collectors/bind.rb b/lib/arel/collectors/bind.rb
new file mode 100644
index 0000000000..4309de75c9
--- /dev/null
+++ b/lib/arel/collectors/bind.rb
@@ -0,0 +1,32 @@
+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
+ end
+ end
+end