aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-05-01 14:02:31 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-05-01 14:02:31 +0100
commitd9954431406a06305a5d970909489d90864f62df (patch)
tree39c07476229b16c6f9dda5908a4330d0583a104a
parent0c95e0543f8e0ffc7e7b3d33799b78e03c1049d2 (diff)
Tidied up sqlite mutex nonsense.
-rw-r--r--lib/dm-sqlite-adapter-with-mutex.rb15
-rw-r--r--test/tc_mauve_database_peculiarities.rb9
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/dm-sqlite-adapter-with-mutex.rb b/lib/dm-sqlite-adapter-with-mutex.rb
index 2842c5e..6c5c022 100644
--- a/lib/dm-sqlite-adapter-with-mutex.rb
+++ b/lib/dm-sqlite-adapter-with-mutex.rb
@@ -5,20 +5,11 @@
require 'dm-sqlite-adapter'
require 'monitor'
-ADAPTER = DataMapper::Adapters::SqliteAdapter
+class 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)
+ include MonitorMixin
-class ADAPTER
-
- def initialize(*a)
- extend(MonitorMixin)
- initialize_old(*a)
- end
+ alias_method :with_connection_old, :with_connection
private
diff --git a/test/tc_mauve_database_peculiarities.rb b/test/tc_mauve_database_peculiarities.rb
index 9eb612e..b29bd95 100644
--- a/test/tc_mauve_database_peculiarities.rb
+++ b/test/tc_mauve_database_peculiarities.rb
@@ -81,5 +81,14 @@ class TcMauveDatabaseSqlite3Peculiarities < TcMauveDatabasePeculiarities
# @pg_conn = PGconn.open(:dbname => @temp_db)
@db_url = "sqlite3::memory:"
end
+
+ #
+ # This just makes sure our mixin has been added to the SqliteAdapter.
+ #
+ def test_has_mixin
+ assert DataMapper::Adapters::SqliteAdapter.private_instance_methods.include?("with_connection_old")
+ assert DataMapper::Adapters::SqliteAdapter.public_instance_methods.include?("synchronize")
+ end
+
end