From 11e29a32af658ee0956b1237fea1033698a457e8 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 9 Dec 2010 14:48:28 -0800 Subject: AND nodes are now n-ary --- lib/arel/nodes/and.rb | 17 +++++++++++++++++ lib/arel/nodes/node.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/arel/nodes') diff --git a/lib/arel/nodes/and.rb b/lib/arel/nodes/and.rb index 80f420b4f1..b087a10930 100644 --- a/lib/arel/nodes/and.rb +++ b/lib/arel/nodes/and.rb @@ -1,6 +1,23 @@ module Arel module Nodes class And < Arel::Nodes::Binary + attr_reader :children + + def initialize children, right = nil + unless Array === children + warn "(#{caller.first}) AND nodes should be created with a list" + children = [children, right] + end + @children = children + end + + def left + children.first + end + + def right + children[1] + end end end end diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb index 567221aab2..ff788e90d2 100644 --- a/lib/arel/nodes/node.rb +++ b/lib/arel/nodes/node.rb @@ -22,7 +22,7 @@ module Arel ### # Factory method to create an Nodes::And node. def and right - Nodes::And.new self, right + Nodes::And.new [self, right] end # FIXME: this method should go away. I don't like people calling -- cgit v1.2.3