Class: IndexChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/uses_index/index_checkers/base.rb

Direct Known Subclasses

PostgresqlIndexChecker, SqliteIndexChecker

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_adapter(connection) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/uses_index/index_checkers/base.rb', line 2

def self.for_adapter(connection)
  adapter_name = connection.adapter_name
  case adapter_name
  when 'SQLite'
    require_relative 'sqlite' unless defined?(SqliteIndexChecker)
    SqliteIndexChecker
  when 'PostgreSQL'
    require_relative 'postgresql' unless defined?(PostgresqlIndexChecker)
    PostgresqlIndexChecker
  else
    raise "Unsupported database adapter: #{adapter_name}. Currently supports SQLite and PostgreSQL."
  end
end

Instance Method Details

#check(query, expected_index, connection = ActiveRecord::Base.connection) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/uses_index/index_checkers/base.rb', line 16

def check(query, expected_index, connection = ActiveRecord::Base.connection)
  raise NotImplementedError, 'Subclasses must implement check'
end

#check_sql(sql, expected_index, connection = ActiveRecord::Base.connection, binds: nil) ⇒ Object

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/uses_index/index_checkers/base.rb', line 20

def check_sql(sql, expected_index, connection = ActiveRecord::Base.connection, binds: nil)
  raise NotImplementedError, 'Subclasses must implement check_sql'
end