diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:39:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:39:50 -0700 |
commit | 89fb88982fb1a678484cd4bdacae37aa4a599a4a (patch) | |
tree | 4ab1314e3712f899882ab28879e2fec0e946be57 /lib/arel/algebra/relations | |
parent | e4eb64bab3eaa40ce22f0d0c7d008c6eea2988ca (diff) | |
download | rails-89fb88982fb1a678484cd4bdacae37aa4a599a4a.tar.gz rails-89fb88982fb1a678484cd4bdacae37aa4a599a4a.tar.bz2 rails-89fb88982fb1a678484cd4bdacae37aa4a599a4a.zip |
unfactoring more metaprogramming
Diffstat (limited to 'lib/arel/algebra/relations')
-rw-r--r-- | lib/arel/algebra/relations/operations/project.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/arel/algebra/relations/operations/project.rb b/lib/arel/algebra/relations/operations/project.rb index 49d0e1be36..2cdae288e3 100644 --- a/lib/arel/algebra/relations/operations/project.rb +++ b/lib/arel/algebra/relations/operations/project.rb @@ -1,10 +1,9 @@ module Arel class Project < Compound - attributes :relation, :projections - deriving :== + attr_reader :projections def initialize(relation, *projections, &block) - @relation = relation + super(relation) @projections = (projections + arguments_from_block(relation, &block)) \ .collect { |p| p.bind(relation) } end @@ -16,5 +15,12 @@ module Arel def externalizable? attributes.any? { |a| a.respond_to?(:aggregation?) && a.aggregation? } || relation.externalizable? end + + def == other + super || + Project === other && + relation == other.relation && + projections == other.projections + end end end |