Sha256: 1a7accb0fe3cbaa1bfc66a25a0acae93ce64541da6413c52d8ac4b52c6d5d8b4

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

class Kredis::Railtie < ::Rails::Railtie
  config.kredis = ActiveSupport::OrderedOptions.new

  initializer "kredis.testing" do
    ActiveSupport.on_load(:active_support_test_case) do
      parallelize_setup { |worker| Kredis.namespace = "test-#{worker}" }
      teardown { Kredis.clear_all }
    end
  end

  initializer "kredis.logger" do
    Kredis::LogSubscriber.logger = config.kredis.logger || Rails.logger
  end

  initializer "kredis.configuration" do
    Kredis::Connections.connector = config.kredis.connector || ->(config) { Redis.new(config) }
  end

  initializer "kredis.configurator" do
    Kredis.configurator = Rails.application
  end

  initializer "kredis.attributes" do
    # No load hook for Active Model, just defer until after initialization.
    config.after_initialize do
      ActiveModel::Model.include Kredis::Attributes if defined?(ActiveModel::Model)
    end

    ActiveSupport.on_load(:active_record) do
      include Kredis::Attributes
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kredis-1.0.0 lib/kredis/railtie.rb