diff options
Diffstat (limited to 'lib/arel/relations/projection.rb')
-rw-r--r-- | lib/arel/relations/projection.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/arel/relations/projection.rb b/lib/arel/relations/projection.rb new file mode 100644 index 0000000000..f09d4f894b --- /dev/null +++ b/lib/arel/relations/projection.rb @@ -0,0 +1,23 @@ +module Arel + class Projection < Compound + attr_reader :projections + + def initialize(relation, *projections) + @relation, @projections = relation, projections + end + + def attributes + projections.collect { |p| p.bind(self) } + end + + def ==(other) + self.class == other.class and + relation == other.relation and + projections == other.projections + end + + def aggregation? + attributes.any?(&:aggregation?) + end + end +end
\ No newline at end of file |