diff options
Diffstat (limited to 'lib/arel/relations/operations/group.rb')
-rw-r--r-- | lib/arel/relations/operations/group.rb | 14 |
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? |