diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 13:47:06 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-04-11 13:47:06 -0700 |
commit | 42c42bfa50876b4221c024cebc47fc34fc6530a9 (patch) | |
tree | 73777a9c4f61330bd89832b312318ffb555afaca /lib | |
parent | 89b354bf97d0a981376d36f2f8a7ba6a87fe2aa8 (diff) | |
download | rails-42c42bfa50876b4221c024cebc47fc34fc6530a9.tar.gz rails-42c42bfa50876b4221c024cebc47fc34fc6530a9.tar.bz2 rails-42c42bfa50876b4221c024cebc47fc34fc6530a9.zip |
moved bind to factory of select
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_relation/predicates.rb | 20 | ||||
-rw-r--r-- | lib/active_relation/relations/relation.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/relations/selection.rb | 3 |
3 files changed, 8 insertions, 17 deletions
diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb index 22fbcd9f0b..e17a9f82fe 100644 --- a/lib/active_relation/predicates.rb +++ b/lib/active_relation/predicates.rb @@ -46,27 +46,19 @@ module ActiveRelation end class GreaterThanOrEqualTo < Binary - def predicate_sql - '>=' - end + def predicate_sql; '>=' end end class GreaterThan < Binary - def predicate_sql - '>' - end + def predicate_sql; '>' end end class LessThanOrEqualTo < Binary - def predicate_sql - '<=' - end + def predicate_sql; '<=' end end class LessThan < Binary - def predicate_sql - '<' - end + def predicate_sql; '<' end end class Match < Binary @@ -74,8 +66,6 @@ module ActiveRelation end class In < Binary - def predicate_sql - operand2.inclusion_predicate_sql - end + def predicate_sql; operand2.inclusion_predicate_sql end end end
\ No newline at end of file diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index db61fce3de..f7e47c2e50 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -38,7 +38,7 @@ module ActiveRelation end def select(*predicates) - Selection.new(self, *predicates.collect {|p| p.bind(self)}) + Selection.new(self, *predicates) end def project(*attributes) diff --git a/lib/active_relation/relations/selection.rb b/lib/active_relation/relations/selection.rb index fe28908cc2..032de63d04 100644 --- a/lib/active_relation/relations/selection.rb +++ b/lib/active_relation/relations/selection.rb @@ -3,8 +3,9 @@ module ActiveRelation attr_reader :predicate def initialize(relation, *predicates) - @predicate = predicates.shift + predicate = predicates.shift @relation = predicates.empty?? relation : Selection.new(relation, *predicates) + @predicate = predicate.bind(@relation) end def ==(other) |