Class: Fatalistic::MySQLLocker

Inherits:
Locker
  • Object
show all
Defined in:
lib/fatalistic.rb

Overview

Table locking for MySQL.

Instance Attribute Summary

Attributes inherited from Locker

#model_class

Instance Method Summary collapse

Methods inherited from Locker

for, #initialize

Constructor Details

This class inherits a constructor from Fatalistic::Locker

Instance Method Details

#lock(lock_statement = nil) ⇒ Object



55
56
57
58
59
60
# File 'lib/fatalistic.rb', line 55

def lock(lock_statement = nil)
  stmt = "LOCK TABLES #{quoted_table_name}"
  lock_statement ||= "WRITE"
  stmt.insert(-1, " #{lock_statement}")
  connection.execute(stmt)
end

#unlockObject



62
63
64
# File 'lib/fatalistic.rb', line 62

def unlock
  connection.execute("UNLOCK TABLES")
end