diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/collectors/plain_string.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/bind_param.rb | 10 | ||||
-rw-r--r-- | lib/arel/visitors/bind_visitor.rb | 40 |
3 files changed, 10 insertions, 42 deletions
diff --git a/lib/arel/collectors/plain_string.rb b/lib/arel/collectors/plain_string.rb index 1e8d2a2152..4c8c15cc9c 100644 --- a/lib/arel/collectors/plain_string.rb +++ b/lib/arel/collectors/plain_string.rb @@ -3,7 +3,7 @@ module Arel module Collectors class PlainString def initialize - @str = ''.dup + @str = String.new end def value diff --git a/lib/arel/nodes/bind_param.rb b/lib/arel/nodes/bind_param.rb index 9e297831cd..d55f4c1c8e 100644 --- a/lib/arel/nodes/bind_param.rb +++ b/lib/arel/nodes/bind_param.rb @@ -2,8 +2,16 @@ module Arel module Nodes class BindParam < Node + attr_reader :value + + def initialize(value) + @value = value + super() + end + def ==(other) - other.is_a?(BindParam) + other.is_a?(BindParam) && + value == other.value end end end diff --git a/lib/arel/visitors/bind_visitor.rb b/lib/arel/visitors/bind_visitor.rb deleted file mode 100644 index 8a5570cf5c..0000000000 --- a/lib/arel/visitors/bind_visitor.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true -module Arel - module Visitors - module BindVisitor - def initialize target - @block = nil - super - end - - def accept node, collector, &block - @block = block if block_given? - super - end - - private - - def visit_Arel_Nodes_Assignment o, collector - if o.right.is_a? Arel::Nodes::BindParam - collector = visit o.left, collector - collector << " = " - visit o.right, collector - else - super - end - end - - def visit_Arel_Nodes_BindParam o, collector - if @block - val = @block.call - if String === val - collector << val - end - else - super - end - end - - end - end -end |