From 068b184a59a98b4acdc63a2833c360199d138c1d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 29 Jul 2010 12:01:08 -0700 Subject: PERF: removing many splats --- lib/arel/algebra/relations/operations/group.rb | 2 +- lib/arel/algebra/relations/operations/having.rb | 2 +- lib/arel/algebra/relations/operations/order.rb | 2 +- lib/arel/algebra/relations/operations/project.rb | 2 +- lib/arel/algebra/relations/operations/where.rb | 2 +- lib/arel/algebra/relations/relation.rb | 14 ++++++-------- 6 files changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/arel') diff --git a/lib/arel/algebra/relations/operations/group.rb b/lib/arel/algebra/relations/operations/group.rb index 89e56b3a98..f3666cacf8 100644 --- a/lib/arel/algebra/relations/operations/group.rb +++ b/lib/arel/algebra/relations/operations/group.rb @@ -2,7 +2,7 @@ module Arel class Group < Compound attr_reader :groupings - def initialize(relation, *groupings) + def initialize(relation, groupings) super(relation) @groupings = groupings.collect { |g| g.bind(relation) } end diff --git a/lib/arel/algebra/relations/operations/having.rb b/lib/arel/algebra/relations/operations/having.rb index 447e836c1a..d36aad071b 100644 --- a/lib/arel/algebra/relations/operations/having.rb +++ b/lib/arel/algebra/relations/operations/having.rb @@ -2,7 +2,7 @@ module Arel class Having < Compound attr_reader :predicates - def initialize(relation, *predicates) + def initialize(relation, predicates) super(relation) @predicates = predicates.map { |p| p.bind(relation) } end diff --git a/lib/arel/algebra/relations/operations/order.rb b/lib/arel/algebra/relations/operations/order.rb index 54be2f5af0..bf0e0f723c 100644 --- a/lib/arel/algebra/relations/operations/order.rb +++ b/lib/arel/algebra/relations/operations/order.rb @@ -2,7 +2,7 @@ module Arel class Order < Compound attr_reader :orderings - def initialize(relation, *orderings) + def initialize(relation, orderings) super(relation) @orderings = orderings.collect { |o| o.bind(relation) } end diff --git a/lib/arel/algebra/relations/operations/project.rb b/lib/arel/algebra/relations/operations/project.rb index 0590b8dd88..649ec19713 100644 --- a/lib/arel/algebra/relations/operations/project.rb +++ b/lib/arel/algebra/relations/operations/project.rb @@ -2,7 +2,7 @@ module Arel class Project < Compound attr_reader :projections, :attributes - def initialize(relation, *projections) + def initialize(relation, projections) super(relation) @projections = projections.map { |p| p.bind(relation) } @attributes = Header.new(projections.map { |x| x.bind(self) }) diff --git a/lib/arel/algebra/relations/operations/where.rb b/lib/arel/algebra/relations/operations/where.rb index 3aa06406cf..3b70b49f3a 100644 --- a/lib/arel/algebra/relations/operations/where.rb +++ b/lib/arel/algebra/relations/operations/where.rb @@ -2,7 +2,7 @@ module Arel class Where < Compound attr_reader :predicates - def initialize(relation, *predicates) + def initialize(relation, predicates) super(relation) @predicates = predicates.map { |p| p.bind(relation) } @wheres = nil diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index e8ef9b395d..dd0684b88e 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -116,19 +116,17 @@ module Arel end %w{ - where order skip group having - }.each do |operation_name| + having group order where project + }.each do |op| class_eval <<-OPERATION, __FILE__, __LINE__ - def #{operation_name}(*arguments) - arguments.all? { |x| x.blank? } ? - self : #{operation_name.capitalize}.new(self, *arguments) + def #{op}(*args) + args.all? { |x| x.blank? } ? self : #{op.capitalize}.new(self, args) end OPERATION end - def project *args - return self if args.all? { |x| x.blank? } - Project.new self, *args + def skip thing = nil + thing ? Skip.new(self, thing) : self end def take thing -- cgit v1.2.3