Class: Arel::Nodes::Function

Inherits:
Node
  • Object
show all
Includes:
Expression
Defined in:
lib/arel/nodes/function.rb

Direct Known Subclasses

Count, NamedFunction

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OrderPredications

#asc, #desc

Methods inherited from Node

#and, #each, #not, #or, #to_sql

Methods included from FactoryMethods

#create_and, #create_join, #create_on, #create_string_join, #create_table_alias, #grouping, #lower

Constructor Details

#initialize(expr, aliaz = nil) ⇒ Function

Returns a new instance of Function.



7
8
9
10
11
# File 'lib/arel/nodes/function.rb', line 7

def initialize expr, aliaz = nil
  @expressions = expr
  @alias       = aliaz && SqlLiteral.new(aliaz)
  @distinct    = false
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



5
6
7
# File 'lib/arel/nodes/function.rb', line 5

def alias
  @alias
end

#distinctObject

Returns the value of attribute distinct.



5
6
7
# File 'lib/arel/nodes/function.rb', line 5

def distinct
  @distinct
end

#expressionsObject

Returns the value of attribute expressions.



5
6
7
# File 'lib/arel/nodes/function.rb', line 5

def expressions
  @expressions
end

Instance Method Details

#as(aliaz) ⇒ Object



13
14
15
16
# File 'lib/arel/nodes/function.rb', line 13

def as aliaz
  self.alias = SqlLiteral.new(aliaz)
  self
end