aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-17 14:43:27 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-17 14:43:27 -0700
commit2e252c4cc8003489185658db1b76bee69be4a010 (patch)
tree2df7a9553013c272bcbd4cc171b2001e3e416fb6 /lib/arel/relations
parent3f55d33e530da1b5c454e0cfe920462d497649c8 (diff)
downloadrails-2e252c4cc8003489185658db1b76bee69be4a010.tar.gz
rails-2e252c4cc8003489185658db1b76bee69be4a010.tar.bz2
rails-2e252c4cc8003489185658db1b76bee69be4a010.zip
slight performance improvement
Diffstat (limited to 'lib/arel/relations')
-rw-r--r--lib/arel/relations/compound.rb7
-rw-r--r--lib/arel/relations/order.rb8
-rw-r--r--lib/arel/relations/selection.rb2
3 files changed, 6 insertions, 11 deletions
diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb
index 6f230c3f57..55b2bc80c7 100644
--- a/lib/arel/relations/compound.rb
+++ b/lib/arel/relations/compound.rb
@@ -10,12 +10,7 @@ module Arel
def attributes
@attributes ||= relation.attributes.collect { |a| a.bind(self) }
end
-
- def selects
- @selects ||= relation.selects.collect { |s| s.bind(self) }
- end
-
- # XXX
+
def relation_for(attribute)
join? && relation.relation_for(attribute) || self[attribute] && self
end
diff --git a/lib/arel/relations/order.rb b/lib/arel/relations/order.rb
index 662d3740df..2d72127722 100644
--- a/lib/arel/relations/order.rb
+++ b/lib/arel/relations/order.rb
@@ -6,14 +6,14 @@ module Arel
@relation, @orderings = relation, orderings.collect { |o| o.bind(relation) }
end
+ def orders
+ orderings + relation.orders
+ end
+
def ==(other)
self.class == other.class and
relation == other.relation and
orderings == other.orderings
end
-
- def orders
- orderings + relation.orders
- end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/selection.rb b/lib/arel/relations/selection.rb
index a37f51c9ec..c50db1c88a 100644
--- a/lib/arel/relations/selection.rb
+++ b/lib/arel/relations/selection.rb
@@ -9,7 +9,7 @@ module Arel
end
def selects
- (relation.selects + [predicate]).collect { |p| p.bind(self) }
+ @selects ||= (relation.selects + [predicate]).collect { |p| p.bind(self) }
end
def ==(other)