Class: Arel::Project
- Defined in:
- lib/arel/engines/memory/relations/operations.rb,
lib/arel/algebra/relations/operations/project.rb
Instance Attribute Summary
Attributes inherited from Compound
Attributes included from Relation
Instance Method Summary collapse
- #attributes ⇒ Object
- #eval ⇒ Object
- #externalizable? ⇒ Boolean
-
#initialize(relation, *projections, &block) ⇒ Project
constructor
A new instance of Project.
Methods inherited from Compound
#build_query, #engine, #eql?, #hash, requires, #unoperated_rows
Methods included from Relation
#bind, #call, #christener, #compiler, #exclusion_predicate_sql, #externalize, #inclusion_predicate_sql, #join?, #primary_key, #session, #to_sql
Methods included from Relation::DefaultOperations
#groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken, #wheres
Methods included from Relation::AttributeAccessable
#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of
Methods included from Relation::Operable
#alias, #join, #lock, #outer_join
Methods included from Relation::Operable::Writable
Methods included from Relation::Enumerable
Constructor Details
#initialize(relation, *projections, &block) ⇒ Project
Returns a new instance of Project.
6 7 8 9 10 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 6 def initialize(relation, *projections, &block) @relation = relation @projections = (projections + arguments_from_block(relation, &block)) \ .collect { |p| p.bind(relation) } end |
Instance Method Details
#attributes ⇒ Object
12 13 14 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 12 def attributes @attributes ||= Header.new(projections).bind(self) end |
#eval ⇒ Object
18 19 20 |
# File 'lib/arel/engines/memory/relations/operations.rb', line 18 def eval unoperated_rows.collect { |r| r.slice(*projections) } end |
#externalizable? ⇒ Boolean
16 17 18 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 16 def externalizable? attributes.any? { |a| a.respond_to?(:aggregation?) && a.aggregation? } || relation.externalizable? end |