Class: Prequel::Expressions::DerivedColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/prequel/expressions/derived_column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

#expressionObject (readonly)

Returns the value of attribute expression.



4
5
6
# File 'lib/prequel/expressions/derived_column.rb', line 4

def expression
  @expression
end

#relationObject (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

#nameObject



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