diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-18 15:08:03 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-18 15:08:03 -0800 |
commit | 2a91d807538a4d39c5755fb83a5e9462e8056fa6 (patch) | |
tree | 93e7f9439c60231a71c8857478333dfdba7c5e2e /lib | |
parent | b0eb6244122a5fd86beaaabb6381835aebb139d4 (diff) | |
download | rails-2a91d807538a4d39c5755fb83a5e9462e8056fa6.tar.gz rails-2a91d807538a4d39c5755fb83a5e9462e8056fa6.tar.bz2 rails-2a91d807538a4d39c5755fb83a5e9462e8056fa6.zip |
made descend public; added test coverage for it; tests for qualify are now in terms of descend
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_relation/predicates.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/aggregation.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/join.rb | 8 | ||||
-rw-r--r-- | lib/active_relation/relations/order.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/projection.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/range.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/relation.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/rename.rb | 1 | ||||
-rw-r--r-- | lib/active_relation/relations/selection.rb | 9 |
9 files changed, 8 insertions, 16 deletions
diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb index 67d910b9d1..c4f7b83512 100644 --- a/lib/active_relation/predicates.rb +++ b/lib/active_relation/predicates.rb @@ -28,7 +28,6 @@ module ActiveRelation "#{attribute.to_sql(strategy)} #{predicate_sql} #{operand.to_sql(strategy)}" end - protected def descend self.class.new(yield(attribute), yield(operand)) end diff --git a/lib/active_relation/relations/aggregation.rb b/lib/active_relation/relations/aggregation.rb index de21d2f383..d3a026820d 100644 --- a/lib/active_relation/relations/aggregation.rb +++ b/lib/active_relation/relations/aggregation.rb @@ -21,7 +21,6 @@ module ActiveRelation true end - protected def descend(&block) Aggregation.new(relation.descend(&block), :expressions => expressions.collect(&block), :groupings => groupings.collect(&block)) end diff --git a/lib/active_relation/relations/join.rb b/lib/active_relation/relations/join.rb index 6185293c8a..850a773ee5 100644 --- a/lib/active_relation/relations/join.rb +++ b/lib/active_relation/relations/join.rb @@ -31,6 +31,10 @@ module ActiveRelation end alias_method :aliased_prefix_for, :prefix_for + def descend(&block) + Join.new(join_sql, relation1.descend(&block), relation2.descend(&block), *predicates.collect(&block)) + end + protected def joins right_table_sql = relation2.aggregation?? relation2.to_sql(Sql::Aggregation.new) : relation2.send(:table_sql) @@ -48,9 +52,5 @@ module ActiveRelation def table_sql relation1.aggregation?? relation1.to_sql(Sql::Aggregation.new) : relation1.send(:table_sql) end - - def descend(&block) - Join.new(join_sql, relation1.descend(&block), relation2.descend(&block), *predicates.collect(&block)) - end end end
\ No newline at end of file diff --git a/lib/active_relation/relations/order.rb b/lib/active_relation/relations/order.rb index cee6278c80..e6395aecd7 100644 --- a/lib/active_relation/relations/order.rb +++ b/lib/active_relation/relations/order.rb @@ -11,7 +11,6 @@ module ActiveRelation orders == other.orders end - protected def descend(&block) Order.new(relation.descend(&block), *orders.collect(&block)) end diff --git a/lib/active_relation/relations/projection.rb b/lib/active_relation/relations/projection.rb index cd08a5aa54..c478ae145f 100644 --- a/lib/active_relation/relations/projection.rb +++ b/lib/active_relation/relations/projection.rb @@ -16,7 +16,6 @@ module ActiveRelation projections == other.projections end - protected def descend(&block) Projection.new(relation.descend(&block), *projections.collect(&block)) end diff --git a/lib/active_relation/relations/range.rb b/lib/active_relation/relations/range.rb index 14a86b8c65..fafdef5902 100644 --- a/lib/active_relation/relations/range.rb +++ b/lib/active_relation/relations/range.rb @@ -19,7 +19,6 @@ module ActiveRelation range.begin end - protected def descend(&block) Range.new(relation.descend(&block), range) end diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index 7d33b42faf..e0ae882475 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -103,7 +103,6 @@ module ActiveRelation end alias_method :to_s, :to_sql - protected def descend yield self end diff --git a/lib/active_relation/relations/rename.rb b/lib/active_relation/relations/rename.rb index 1705d9ba8c..9a0e5552c7 100644 --- a/lib/active_relation/relations/rename.rb +++ b/lib/active_relation/relations/rename.rb @@ -18,7 +18,6 @@ module ActiveRelation relation.attributes.collect(&method(:baptize)) end - protected def descend(&block) Rename.new(relation.descend(&block), yield(attribute) => pseudonym) end diff --git a/lib/active_relation/relations/selection.rb b/lib/active_relation/relations/selection.rb index f8cd235419..e7a91f7572 100644 --- a/lib/active_relation/relations/selection.rb +++ b/lib/active_relation/relations/selection.rb @@ -13,14 +13,13 @@ module ActiveRelation predicate == other.predicate end - protected - def selects - relation.send(:selects) + [predicate] - end - def descend(&block) Selection.new(relation.descend(&block), yield(predicate)) end + protected + def selects + relation.send(:selects) + [predicate] + end end end
\ No newline at end of file |