class ArelExtensions::Nodes::Concat
Constants
- RETURN_TYPE
Public Class Methods
new(expr)
click to toggle source
Calls superclass method
# File lib/arel_extensions/nodes/concat.rb, line 5 def initialize expr tab = expr.map { |arg| # flatten nested concats. node = convert_to_node(arg) if node.is_a?(Concat) node.expressions else node end }.flatten.reduce([]) { |res, b| # concatenate successive literal strings. if b.is_a?(Arel::Nodes::Quoted) && b.expr == '' res elsif res.last && res.last.is_a?(Arel::Nodes::Quoted) && b.is_a?(Arel::Nodes::Quoted) res[-1] = Arel.quoted(res.last.expr + b.expr) else res << b end res } super(tab) end
new(expr)
click to toggle source
Calls superclass method
# File lib/arel_extensions/nodes/concat.rb, line 28 def self.new expr o = super(expr) if o.expressions.length == 1 o.expressions[0] else o end end
Public Instance Methods
concat(other)
click to toggle source
# File lib/arel_extensions/nodes/concat.rb, line 37 def concat(other) Concat.new(self.expressions + [other]) end