Permalink
Browse files

properly overwrite #reload, no matter when #setup! is called

git-svn-id: http://ar-code.svn.engineyard.com/plugins/masochism@32 d98f8484-0aa7-43af-80ea-302c351499d6
  • Loading branch information...
1 parent 720142f commit 238f22d847e3b15f687a8280303c026e4d6d7e8f rick committed Oct 6, 2007
Showing with 9 additions and 10 deletions.
  1. +9 −10 lib/active_reload/connection_proxy.rb
@@ -19,6 +19,7 @@ def self.setup!
def self.setup_for(master, slave = nil)
slave ||= ActiveRecord::Base
+ slave.send :include, ActiveRecordConnectionMethods
ActiveRecord::Base.active_connections[slave.name] = new(master, slave)
end
@@ -49,16 +50,14 @@ def method_missing(method, *args, &block)
@current.send(method, *args, &block)
end
end
-end
-
-class << ActiveRecord::Base
- def inherited_with_master(base)
- base.class_eval do
- def reload(*args, &block)
- connection.with_master { super }
- end
+
+ module ActiveRecordConnectionMethods
+ def self.included(base)
+ base.alias_method_chain :reload, :master
+ end
+
+ def reload_with_master(*args, &block)
+ connection.with_master { reload_without_master }
end
end
-
- alias_method_chain :inherited, :master
end

0 comments on commit 238f22d

Please sign in to comment.