Module: Monogamy::WithTableLock

Defined in:
lib/monogamy/with_table_lock.rb

Instance Method Summary collapse

Instance Method Details

#with_table_lock(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/monogamy/with_table_lock.rb', line 11

def with_table_lock(&block)
  adapter = case (connection.adapter_name.downcase)
    when 'postgresql', 'empostgresql', 'postgis'
      Monogamy::PostgreSQL
    when 'mysql', 'mysql2'
      Monogamy::MySQL
    else
      raise NotImplementedError, "Support for #{connection.adapter_name} has not been written"
  end
  adapter.with_table_lock(connection, quoted_table_name, &block)
end