Class: Squeel::Nodes::Function

Inherits:
Node
  • Object
show all
Includes:
Aliasing, Operators, Ordering, PredicateMethods, PredicateOperators
Defined in:
lib/squeel/nodes/function.rb

Overview

A node that represents an SQL function call

Direct Known Subclasses

Operation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Aliasing

#as

Methods included from Ordering

#asc, #desc

Methods included from Operators

#*, #+, #-, #/, #op

Methods included from PredicateOperators

#&, #-@, #|

Methods included from PredicateMethods

#eq

Methods inherited from Node

#each, #grep

Constructor Details

#initialize(function_name, args) ⇒ Function

Create a node representing an SQL Function with the given name and arguments

Parameters:

  • name (Symbol)

    The function name

  • args (Array)

    The array of arguments to pass to the function.



33
34
35
# File 'lib/squeel/nodes/function.rb', line 33

def initialize(function_name, args)
  @function_name, @args = function_name, args
end

Instance Attribute Details

#argsArray (readonly)

Returns The arguments to be passed to the SQL function.

Returns:

  • (Array)

    The arguments to be passed to the SQL function



28
29
30
# File 'lib/squeel/nodes/function.rb', line 28

def args
  @args
end

#function_nameSymbol (readonly)

Returns The name of the SQL function to be called.

Returns:

  • (Symbol)

    The name of the SQL function to be called



25
26
27
# File 'lib/squeel/nodes/function.rb', line 25

def function_name
  @function_name
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/squeel/nodes/function.rb', line 49

def eql?(other)
  self.class == other.class &&
    self.function_name.eql?(other.function_name) &&
    self.args.eql?(other.args)
end

#hashObject



45
46
47
# File 'lib/squeel/nodes/function.rb', line 45

def hash
  [@name, @args].hash
end

#to_symNilClass

expand_hash_conditions_for_aggregates assumes our hash keys can be converted to symbols, so this has to be implemented, but it doesn’t really have to do anything useful.

Returns:

  • (NilClass)

    Just to avoid bombing out on expand_hash_conditions_for_aggregates



41
42
43
# File 'lib/squeel/nodes/function.rb', line 41

def to_sym
  nil
end