lib/octoshark/connection_pools_manager.rb in octoshark-0.2.0 vs lib/octoshark/connection_pools_manager.rb in octoshark-0.2.1

- old
+ new

@@ -63,23 +63,32 @@ private def spec_class if defined?(ActiveRecord::ConnectionAdapters::ConnectionSpecification) spec_class = ActiveRecord::ConnectionAdapters::ConnectionSpecification else + # Rails 3.0, 3.1 and 3.2 spec_class = ActiveRecord::Base::ConnectionSpecification end end def setup_connection_pools @connection_pools = HashWithIndifferentAccess.new @configs.each_pair do |name, config| - @connection_pools[name] = create_connection_pool(config) + @connection_pools[name] = create_connection_pool(name, config) end end - def create_connection_pool(config) - spec = spec_class.new(config, "#{config[:adapter]}_connection") + def create_connection_pool(name, config) + adapter_method = "#{config[:adapter]}_connection" + spec = + if spec_class.instance_method(:initialize).arity == 3 + # Rails 5 ConnectionSpecification accepts spec name + spec_class.new(name, config, adapter_method) + else + spec_class.new(config, adapter_method) + end + ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec) end end end