Class: WithAdvisoryLock::DatabaseAdapterSupport

Inherits:
Object
  • Object
show all
Defined in:
lib/with_advisory_lock/database_adapter_support.rb

Constant Summary collapse

@@mysql_nl_cache =

Caches nested lock support by MySQL reported version

{}
@@mysql_nl_cache_mutex =
Mutex.new

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ DatabaseAdapterSupport

Returns a new instance of DatabaseAdapterSupport.



9
10
11
12
# File 'lib/with_advisory_lock/database_adapter_support.rb', line 9

def initialize(connection)
  @connection = connection
  @sym_name   = connection.adapter_name.downcase.to_sym
end

Instance Method Details

#mysql?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/with_advisory_lock/database_adapter_support.rb', line 14

def mysql?
  %i[mysql2 trilogy].include? @sym_name
end

#postgresql?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/with_advisory_lock/database_adapter_support.rb', line 18

def postgresql?
  %i[postgresql empostgresql postgis].include? @sym_name
end

#sqlite?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/with_advisory_lock/database_adapter_support.rb', line 22

def sqlite?
  @sym_name == :sqlite3
end