public
Description: ActiveRecord connection proxy for master/slave connections
Clone URL: git://github.com/technoweenie/masochism.git
delegate #execute to master [javier ramirez]
technoweenie (author)
Sun May 18 16:49:44 -0700 2008
commit  cccfa41154f28953944f063c9682a4a05308e861
tree    c1dfc23e5b75ddfde507ffcce48a5e984464cb23
parent  a6933cae9b2634461006c17f7a5412237ef3e8bb
...
20
21
22
23
24
25
26
27
28
...
44
45
46
47
 
48
49
50
...
64
65
66
67
 
 
 
 
68
69
70
...
20
21
22
 
 
 
23
24
25
...
41
42
43
 
44
45
46
47
...
61
62
63
 
64
65
66
67
68
69
70
0
@@ -20,9 +20,6 @@ module ActiveReload
0
     def self.setup_for(master, slave = nil)
0
       slave ||= ActiveRecord::Base
0
       slave.send :include, ActiveRecordConnectionMethods
0
- # extend observer to always use the master database
0
- # observers only get triggered on writes, so shouldn't be a performance hit
0
- # removes a race condition if you are using conditionals in the observer
0
       ActiveRecord::Observer.send :include, ActiveReload::ObserverExtensions
0
       ActiveRecord::Base.active_connections[slave.name] = new(master, slave)
0
     end
0
@@ -44,7 +41,7 @@ module ActiveReload
0
     
0
     delegate :insert, :update, :delete, :create_table, :rename_table, :drop_table, :add_column, :remove_column,
0
       :change_column, :change_column_default, :rename_column, :add_index, :remove_index, :initialize_schema_information,
0
- :dump_schema_information, :to => :master
0
+ :dump_schema_information, :execute, :to => :master
0
     
0
     def transaction(start_db_transaction = true, &block)
0
       with_master { @current.transaction(start_db_transaction, &block) }
0
@@ -64,7 +61,10 @@ module ActiveReload
0
       connection.with_master { reload_without_master }
0
     end
0
   end
0
-
0
+
0
+ # extend observer to always use the master database
0
+ # observers only get triggered on writes, so shouldn't be a performance hit
0
+ # removes a race condition if you are using conditionals in the observer
0
   module ObserverExtensions
0
     def self.included(base)
0
       base.alias_method_chain :update, :masterdb

Comments

    No one has commented yet.