Sha256: 336c119b8cfedad336e2f534c6b064ae69a6293d6878609e7565c134b6c3b546

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

require "rails/railtie"

module Kredis
  class 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.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
end

Version data entries

1 entries across 1 versions & 1 rubygems

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