From 75bfee8cc15ca8bd07629c6e7b6f0950dcb2d864 Mon Sep 17 00:00:00 2001 From: Paul Sadauskas Date: Fri, 21 Jan 2011 17:40:44 -0700 Subject: With node takes an array, less code to determine alternative nodes --- lib/arel/nodes/with.rb | 9 +-------- lib/arel/select_manager.rb | 12 ++---------- 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/arel/nodes/with.rb b/lib/arel/nodes/with.rb index ce1644b60e..0745080cc3 100644 --- a/lib/arel/nodes/with.rb +++ b/lib/arel/nodes/with.rb @@ -1,14 +1,7 @@ module Arel module Nodes class With < Arel::Nodes::Unary - attr_reader :children - alias value children - alias expr children - - def initialize *children - @children = children - end - + alias children expr end class WithRecursive < With; end diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb index 4f510d096b..22e3dd07e0 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -136,11 +136,7 @@ module Arel def union operation, other = nil if operation.is_a? Symbol - if operation === :all - node_class = Nodes::UnionAll - else - raise "Only supported UNION operation is :all" - end + node_class = Nodes.const_get("Union#{operation.to_s.capitalize}") else other = operation node_class = Nodes::Union @@ -151,11 +147,7 @@ module Arel def with *subqueries if subqueries.first.is_a? Symbol - if subqueries.shift == :recursive - node_class = Nodes::WithRecursive - else - raise "Only supported WITH modifier is :recursive" - end + node_class = Nodes.const_get("With#{subqueries.shift.to_s.capitalize}") else node_class = Nodes::With end -- cgit v1.2.3