Sha256: 931e5e10b38eba89aa08b1704562f41a1d1bbed330ad83997eb400847551c5a6

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require 'active_support/lazy_load_hooks'

ActiveSupport.on_load(:active_record) do
  require 'fresh_connection/extend/ar_base'
  require 'fresh_connection/extend/ar_relation'
  require 'fresh_connection/extend/connection_handler'
  require 'fresh_connection/extend/mysql2_adapter'
  require 'active_record/connection_adapters/mysql2_adapter'

  ActiveRecord::Base.extend FreshConnection::Extend::ArBase

  ActiveRecord::Relation.__send__(:include, FreshConnection::Extend::ArRelation)

  ActiveRecord::ConnectionAdapters::ConnectionHandler.__send__(
    :include, FreshConnection::Extend::ConnectionHandler
  )

  ActiveRecord::ConnectionAdapters::Mysql2Adapter.__send__(
    :include, FreshConnection::Extend::Mysql2Adapter
  )

  if defined?(ActiveRecord::StatementCache)
    require 'fresh_connection/extend/ar_statement_cache'
    ActiveRecord::StatementCache.__send__(:include, FreshConnection::Extend::ArStatementCache)
  end

  ActiveRecord::Base.establish_fresh_connection
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fresh_connection-0.3.0 lib/fresh_connection/extend.rb