aboutsummaryrefslogtreecommitdiff
path: root/lib/dm-sqlite-adapter-with-mutex.rb
blob: 6c5c02217db723c876074396a78fafa1c6d6f10a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#
# Add a mutex so that we can avoid the 'database is locked' Sqlite3Error
# exception.
#
require 'dm-sqlite-adapter'
require 'monitor'

class DataMapper::Adapters::SqliteAdapter

  include MonitorMixin

  alias_method :with_connection_old, :with_connection

  private

  def with_connection(&block)
    synchronize { with_connection_old(&block) }
  end
end