Sha256: 095581e89c8009661469dadbd648b48fc7b2c19a0248472aa1d528a0d82fe9c9

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 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.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

3 entries across 3 versions & 1 rubygems

Version Path
kredis-0.4.0 lib/kredis/railtie.rb
kredis-0.3.1 lib/kredis/railtie.rb
kredis-0.3.0 lib/kredis/railtie.rb