module BabySqueel::Nodes

Public Class Methods

unwrap(node) click to toggle source

Unwraps a BabySqueel::Proxy before being passed to ActiveRecord.

# File lib/baby_squeel/nodes.rb, line 29
def unwrap(node)
  if node.respond_to? :_arel
    unwrap node._arel
  elsif node.is_a? Array
    node.map { |n| unwrap(n) }
  else
    node
  end
end
wrap(arel) click to toggle source

Wraps an Arel node in a Proxy so that it can be extended.

# File lib/baby_squeel/nodes.rb, line 12
def wrap(arel)
  case arel
  when Arel::Nodes::Grouping
    Grouping.new(arel)
  when Arel::Nodes::Function
    Function.new(arel)
  when Arel::Nodes::Binary
    Binary.new(arel)
  when Arel::Nodes::Node, Arel::Nodes::SqlLiteral
    Node.new(arel)
  else
    arel
  end
end