Sha256: ecbc91ba6cf7774432111738dfdb1d36cd8f167d4e567bc200859e3adeb6ab24

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

module ActiveRecord::Turntable
  class Railtie < Rails::Railtie
    rake_tasks do
      require 'active_record/turntable/active_record_ext/database_tasks'
      load "active_record/turntable/railties/databases.rake"
    end

    # rails loading hook
    ActiveSupport.on_load(:before_initialize) do
      ActiveSupport.on_load(:active_record) do
        ActiveRecord::Base.send(:include, ActiveRecord::Turntable)
      end
    end

    # initialize
    initializer "turntable.initialize_clusters" do
      ActiveSupport.on_load(:active_record) do
        if File.exist?(ActiveRecord::Base.turntable_config_file)
          ActiveRecord::Turntable::Config.load!
        else
          warn("[activerecord-turntable] config/turntable.yml is not found. skipped initliazing cluster.")
        end
      end
    end

    # QueryCache Middleware for turntable shards
    initializer "turntable.insert_query_cache_middleware" do |app|
      app.middleware.insert_after ActiveRecord::QueryCache, ActiveRecord::Turntable::Rack::QueryCache
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
activerecord-turntable-2.5.0 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.4.0 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.3.3 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.3.2 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.3.1 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.3.0 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.2.2 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.2.1 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.2.0 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.1.1 lib/active_record/turntable/railtie.rb
activerecord-turntable-2.1.0 lib/active_record/turntable/railtie.rb