class ActionBlocks::DatabaseFunctions

Public Instance Methods

count(node, *args) click to toggle source
# File lib/action_blocks/data_engine/database_functions.rb, line 16
def count(node, *args)
  Arel::Nodes::NamedFunction.new(
    'count',
    [node]
  )
end
every(predicate, value, node, *args) click to toggle source
# File lib/action_blocks/data_engine/database_functions.rb, line 30
def every(predicate, value, node, *args)
  every_part = Arel::Nodes::NamedFunction.new(
    'every',
    [node.send(predicate, Arel::Nodes.build_quoted(value))]
  )

  Arel::Nodes::NamedFunction.new('CAST', [every_part.as('TEXT')])
end
string_agg(delimiter, node, *args) click to toggle source
# File lib/action_blocks/data_engine/database_functions.rb, line 23
def string_agg(delimiter, node, *args)
  Arel::Nodes::NamedFunction.new(
    'string_agg',
    [node, Arel::Nodes.build_quoted(delimiter)]
  )
end
timezone(tz, node, user, *args) click to toggle source

methods define their own params, always followed by current node and current user

# File lib/action_blocks/data_engine/database_functions.rb, line 4
def timezone(tz, node, user, *args)
  utc = Arel::Nodes::NamedFunction.new(
    'timezone',
    [Arel::Nodes.build_quoted('UTC'), node]
  )

  Arel::Nodes::NamedFunction.new(
    'timezone',
    [Arel::Nodes.build_quoted(tz), utc]
  )
end