diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 14:08:42 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 14:08:42 -0700 |
commit | e8966bf9a86afb82c658cedd7e4baffa3a15a856 (patch) | |
tree | 8705c27da734888b2ca9713182ac3a837026cb99 /lib/arel/relations/utilities/aggregation.rb | |
parent | 518db17ca3dade07fc67b6044b63c826cefb1442 (diff) | |
download | rails-e8966bf9a86afb82c658cedd7e4baffa3a15a856.tar.gz rails-e8966bf9a86afb82c658cedd7e4baffa3a15a856.tar.bz2 rails-e8966bf9a86afb82c658cedd7e4baffa3a15a856.zip |
reorganized file structure
Diffstat (limited to 'lib/arel/relations/utilities/aggregation.rb')
-rw-r--r-- | lib/arel/relations/utilities/aggregation.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/arel/relations/utilities/aggregation.rb b/lib/arel/relations/utilities/aggregation.rb new file mode 100644 index 0000000000..66150bff0a --- /dev/null +++ b/lib/arel/relations/utilities/aggregation.rb @@ -0,0 +1,40 @@ +module Arel + class Aggregation < Compound + include Recursion::BaseCase + + def initialize(relation) + @relation = relation + end + + def wheres + [] + end + + def table_sql(formatter = Sql::TableReference.new(relation)) + formatter.select relation.select_sql, self + end + + def attributes + @attributes ||= relation.attributes.collect(&:to_attribute).collect { |a| a.bind(self) } + end + + def name + relation.name + '_aggregation' + end + + def ==(other) + Aggregation === other and + self.relation == other.relation + end + end + + class Relation + def externalize + @externalized ||= aggregation?? Aggregation.new(self) : self + end + + def aggregation? + false + end + end +end
\ No newline at end of file |