lib/rage-rb.rb in rage-rb-1.2.2 vs lib/rage-rb.rb in rage-rb-1.3.0
- old
+ new
@@ -69,11 +69,38 @@
def self.code_loader
@code_loader ||= Rage::CodeLoader.new
end
+ def self.patch_active_record_connection_pool
+ patch = proc do
+ is_connected = ActiveRecord::Base.connection_pool rescue false
+ if is_connected
+ puts "INFO: Patching ActiveRecord::ConnectionPool"
+ Iodine.on_state(:on_start) do
+ ActiveRecord::Base.connection_pool.extend(Rage::Ext::ActiveRecord::ConnectionPool)
+ ActiveRecord::Base.connection_pool.__init_rage_extension
+ end
+ else
+ puts "WARNING: DB connection is not established - can't patch ActiveRecord::ConnectionPool"
+ end
+ end
+
+ if Rage.config.internal.rails_mode
+ Rails.configuration.after_initialize(&patch)
+ else
+ patch.call
+ end
+ end
+
module Router
module Strategies
+ end
+ end
+
+ module Ext
+ module ActiveRecord
+ autoload :ConnectionPool, "rage/ext/active_record/connection_pool"
end
end
end
module RageController