diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-01-12 20:18:52 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-01-12 20:18:52 -0800 |
commit | a83efc5d5d94d50589a80bdd27ddf5b83ed39810 (patch) | |
tree | d85ad7f670b2c4a7e8af62d96d8f95ecfebfbafa /lib/active_relation/primitives/aggregation.rb | |
parent | 45d2557ae097da1e5dd3dc532444233b4fed0b31 (diff) | |
download | rails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.tar.gz rails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.tar.bz2 rails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.zip |
added aggregations
Diffstat (limited to 'lib/active_relation/primitives/aggregation.rb')
-rw-r--r-- | lib/active_relation/primitives/aggregation.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/active_relation/primitives/aggregation.rb b/lib/active_relation/primitives/aggregation.rb new file mode 100644 index 0000000000..20fdcf46c5 --- /dev/null +++ b/lib/active_relation/primitives/aggregation.rb @@ -0,0 +1,21 @@ +module ActiveRelation + module Primitives + class Aggregation + include SqlBuilder + + attr_reader :attribute, :function_sql + + def initialize(attribute, function_sql) + @attribute, @function_sql = attribute, function_sql + end + + def to_sql(options = {}) + "#{function_sql}(@attribute.to_sql)" + end + + def ==(other) + self.class == other.class and attribute == other.attribute and function_sql == other.function_sql + end + end + end +end
\ No newline at end of file |