Sha256: f2afdc0bc4ccf1cf5263693d99dfe5e65c8c1ffe48eacd895083c3e38292d21c

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

require 'adapter_extensions/base'

class ActiveRecord::Base
  class << self
    # for 1.8.7, modules loaded more than once that use alias_method_chain will 
    # cause stack level too deep errors - make sure we avoid this
    unless self.instance_methods.include?('establish_connection_without_adapter_extensions')
      def establish_connection_with_adapter_extensions(*args)
        establish_connection_without_adapter_extensions(*args)
        ActiveSupport.run_load_hooks(:active_record_connection_established, connection_pool)
      end
      alias_method_chain :establish_connection, :adapter_extensions
    end
  end
end

ActiveSupport.on_load(:active_record_connection_established) do |connection_pool|
  AdapterExtensions.load_from_connection_pool connection_pool
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adapter_extensions-1.0.0 lib/adapter_extensions.rb
adapter_extensions-1.0.0.rc1 lib/adapter_extensions.rb