class Compendium::CountQuery

A CountQuery is a Query which runs an SQL count statement Often useful in conjunction with a grouped query

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/compendium/count_query.rb, line 9
def initialize(*args)
  super

  @options.reverse_merge!(order: 'COUNT(*)', reverse: true)
end

Private Instance Methods

execute_command(command) click to toggle source
# File lib/compendium/count_query.rb, line 17
def execute_command(command)
  return [] if command.nil?
  raise InvalidCommand unless command.respond_to?(:count)
  command.count
end