From 6da9e6d6818b3f33b73e929ea57c40ea8d2f1829 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 20 Jul 2010 17:37:03 -0700 Subject: unfactoring more meta programming --- lib/arel/algebra/relations/operations/group.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/arel/algebra') diff --git a/lib/arel/algebra/relations/operations/group.rb b/lib/arel/algebra/relations/operations/group.rb index 2bfc42214b..68c626e917 100644 --- a/lib/arel/algebra/relations/operations/group.rb +++ b/lib/arel/algebra/relations/operations/group.rb @@ -1,12 +1,18 @@ module Arel class Group < Compound - attributes :relation, :groupings - deriving :== + attr_reader :groupings def initialize(relation, *groupings, &block) - @relation = relation + super(relation) @groupings = (groupings + arguments_from_block(relation, &block)) \ .collect { |g| g.bind(relation) } end + + def == other + super || + self.class === other && + @relation == other.relation && + @groupings == other.groupings + end end end -- cgit v1.2.3