Class: Arel::Project
- Defined in:
- lib/arel/algebra/relations/operations/project.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#christener ⇒ Object
readonly
Returns the value of attribute christener.
-
#projections ⇒ Object
readonly
Returns the value of attribute projections.
Attributes inherited from Compound
Attributes included from Relation
Instance Method Summary collapse
- #eval ⇒ Object
- #externalizable? ⇒ Boolean
-
#initialize(relation, projections) ⇒ Project
constructor
A new instance of Project.
Methods inherited from Compound
#column_for, #join?, #joins, #name, #skipped, #sources, #table, #table_alias, #table_sql, #taken, #unoperated_rows
Methods included from Relation
#[], #alias, #bind, #call, #compiler, #delete, #each, #exclusion_predicate_sql, #externalize, #find_attribute_matching_name, #from, #from_clauses, #group_clauses, #groupings, #having_clauses, #havings, #inclusion_predicate_sql, #insert, #inserts, #join, #join?, #joins, #lock, #locked, #order_clauses, #orders, #outer_join, #position_of, #primary_key, #project, #select_clauses, #session, #skip, #skipped, #sources, #take, #taken, #to_sql, #update, #where, #where_clauses, #wheres
Constructor Details
#initialize(relation, projections) ⇒ Project
Returns a new instance of Project.
5 6 7 8 9 10 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 5 def initialize(relation, projections) super(relation) @projections = projections.map { |p| p.bind(relation) } @christener = Sql::Christener.new @attributes = Header.new(projections.map { |x| x.bind(self) }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 3 def attributes @attributes end |
#christener ⇒ Object (readonly)
Returns the value of attribute christener.
3 4 5 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 3 def christener @christener end |
#projections ⇒ Object (readonly)
Returns the value of attribute projections.
3 4 5 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 3 def projections @projections end |
Instance Method Details
#eval ⇒ Object
16 17 18 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 16 def eval unoperated_rows.collect { |r| r.slice(*projections) } end |
#externalizable? ⇒ Boolean
12 13 14 |
# File 'lib/arel/algebra/relations/operations/project.rb', line 12 def externalizable? attributes.any? { |a| a.respond_to?(:aggregation?) && a.aggregation? } || relation.externalizable? end |