blob: 2842c5e61153b4d5fd2dcfdc3acc354854b75d40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#
# Add a mutex so that we can avoid the 'database is locked' Sqlite3Error
# exception.
#
require 'dm-sqlite-adapter'
require 'monitor'
ADAPTER = DataMapper::Adapters::SqliteAdapter
# better way to alias a private method? (other than "don't"? :) )
ADAPTER.__send__(:alias_method, :initialize_old, :initialize)
ADAPTER.__send__(:undef_method, :initialize)
ADAPTER.__send__(:alias_method, :with_connection_old, :with_connection)
ADAPTER.__send__(:undef_method, :with_connection)
class ADAPTER
def initialize(*a)
extend(MonitorMixin)
initialize_old(*a)
end
private
def with_connection(&block)
synchronize { with_connection_old(&block) }
end
end
|