aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/operations/group.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-19 19:27:48 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-19 19:27:48 -0700
commit9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e (patch)
treeb6f762f065574a6394da1a4c70efb874802d6677 /lib/arel/relations/operations/group.rb
parent5a5501cde76bbba69bcea27d3d0efeaffa3e3bf5 (diff)
downloadrails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.tar.gz
rails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.tar.bz2
rails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.zip
some drying up of boiler plate initialization and equality code
Diffstat (limited to 'lib/arel/relations/operations/group.rb')
-rw-r--r--lib/arel/relations/operations/group.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/arel/relations/operations/group.rb b/lib/arel/relations/operations/group.rb
index bc3a7f3437..22af2734a6 100644
--- a/lib/arel/relations/operations/group.rb
+++ b/lib/arel/relations/operations/group.rb
@@ -1,15 +1,11 @@
module Arel
class Group < Compound
- attr_reader :groupings
+ attributes :relation, :groupings
+ deriving :==
- def initialize(relation, *groupings)
- @relation, @groupings = relation, groupings.collect { |g| g.bind(relation) }
- end
-
- def ==(other)
- Group === other and
- relation == other.relation and
- groupings == other.groupings
+ def initialize(relation, *groupings, &block)
+ @relation = relation
+ @groupings = (groupings + (block_given?? [yield(self)] : [])).collect { |g| g.bind(relation) }
end
def aggregation?