Sha256: e353959ae73e96935c56137917babebea7f114c587943c3f7a0772616d5c504f

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true
require 'active_support'

ActiveSupport.on_load(:active_record) do
  if respond_to?(:connection_handlers) && connection_handlers.empty?
    self.connection_handlers = { writing_role => ActiveRecord::Base.default_connection_handler }
  end

  require 'fresh_connection/extend/ar_base'
  require 'fresh_connection/extend/ar_relation'
  require 'fresh_connection/extend/ar_relation_merger'
  require 'fresh_connection/extend/ar_statement_cache'

  ActiveRecord::Base.extend FreshConnection::Extend::ArBase
  ActiveRecord::Relation.prepend FreshConnection::Extend::ArRelation
  ActiveRecord::Relation::Merger.prepend FreshConnection::Extend::ArRelationMerger
  ActiveRecord::StatementCache.prepend FreshConnection::Extend::ArStatementCache

  if ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR == 1
    require 'fresh_connection/extend/ar_connection_handler'
    ActiveRecord::ConnectionAdapters::ConnectionHandler.prepend(
      FreshConnection::Extend::ArConnectionHandler
    )

    require 'fresh_connection/connection_specification/rails_61'
    FreshConnection::ConnectionSpecification.include(
      FreshConnection::ConnectionSpecification::Rails61
    )
  else
    require 'fresh_connection/extend/ar_resolver'
    ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.prepend(
      FreshConnection::Extend::ArResolver
    )

    require 'fresh_connection/connection_specification/rails_60'
    FreshConnection::ConnectionSpecification.include(
      FreshConnection::ConnectionSpecification::Rails60
    )
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fresh_connection-3.1.3 lib/fresh_connection/extend.rb
fresh_connection-3.1.2 lib/fresh_connection/extend.rb
fresh_connection-3.1.1 lib/fresh_connection/extend.rb
fresh_connection-3.1.1.rc1 lib/fresh_connection/extend.rb