Class: Prequel::Expressions::DerivedColumn
- Inherits:
-
Object
- Object
- Prequel::Expressions::DerivedColumn
- Defined in:
- lib/prequel/expressions/derived_column.rb
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
-
#initialize(relation, expression, alias_name) ⇒ DerivedColumn
constructor
A new instance of DerivedColumn.
- #name ⇒ Object
- #resolve_in_query(query) ⇒ Object
Constructor Details
#initialize(relation, expression, alias_name) ⇒ DerivedColumn
Returns a new instance of DerivedColumn.
7 8 9 |
# File 'lib/prequel/expressions/derived_column.rb', line 7 def initialize(relation, expression, alias_name) @relation, @expression, @alias_name = relation, expression, alias_name end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
4 5 6 |
# File 'lib/prequel/expressions/derived_column.rb', line 4 def alias_name @alias_name end |
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
4 5 6 |
# File 'lib/prequel/expressions/derived_column.rb', line 4 def expression @expression end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
4 5 6 |
# File 'lib/prequel/expressions/derived_column.rb', line 4 def relation @relation end |
Instance Method Details
#name ⇒ Object
11 12 13 |
# File 'lib/prequel/expressions/derived_column.rb', line 11 def name alias_name || expression.name end |
#resolve_in_query(query) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/prequel/expressions/derived_column.rb', line 15 def resolve_in_query(query) if subquery = query.singular_table_refs[relation] subquery.resolve_derived_column(self) else expression.resolve_in_query(query) end end |