Class: Arel::Nodes::Function

Inherits:
NodeExpression show all
Includes:
WindowPredications
Defined in:
lib/arel/nodes/function.rb

Direct Known Subclasses

Count, NamedFunction

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WindowPredications

#over

Methods included from Math

#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~@

Methods included from OrderPredications

#asc, #desc

Methods included from Predications

#between, #concat, #does_not_match, #does_not_match_all, #does_not_match_any, #does_not_match_regexp, #eq, #eq_all, #eq_any, #gt, #gt_all, #gt_any, #gteq, #gteq_all, #gteq_any, #in, #in_all, #in_any, #is_distinct_from, #is_not_distinct_from, #lt, #lt_all, #lt_any, #lteq, #lteq_all, #lteq_any, #matches, #matches_all, #matches_any, #matches_regexp, #not_between, #not_eq, #not_eq_all, #not_eq_any, #not_in, #not_in_all, #not_in_any, #when

Methods included from Expressions

#average, #count, #extract, #maximum, #minimum, #sum

Methods inherited from Node

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

Methods included from FactoryMethods

#coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower

Constructor Details

#initialize(expr, aliaz = nil) ⇒ Function

Returns a new instance of Function.



9
10
11
12
13
14
# File 'lib/arel/nodes/function.rb', line 9

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

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



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

def alias
  @alias
end

#distinctObject

Returns the value of attribute distinct.



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

def distinct
  @distinct
end

#expressionsObject

Returns the value of attribute expressions.



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

def expressions
  @expressions
end

Instance Method Details

#as(aliaz) ⇒ Object



16
17
18
19
# File 'lib/arel/nodes/function.rb', line 16

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

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/arel/nodes/function.rb', line 25

def eql?(other)
  self.class == other.class &&
    self.expressions == other.expressions &&
    self.alias == other.alias &&
    self.distinct == other.distinct
end

#hashObject



21
22
23
# File 'lib/arel/nodes/function.rb', line 21

def hash
  [@expressions, @alias, @distinct].hash
end