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