Sha256: 343ffc905e5d614f57daa15921ff77140d299ac145e9315cfba76db49d950c60

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

if defined?(Rails::Railtie)
  module RailsConfig
    class Railtie < Rails::Railtie

      # manually load the custom initializer before everything else
      initializer :load_custom_rails_config, :before => :bootstrap_hook do
        initializer = Rails.root.join("config", "initializers", "rails_config")
        require initializer if File.exist?(initializer)
      end

      # Parse the settings before any of the initializers
      ActiveSupport.on_load :before_initialize, :yield => true do
        settings = RailsConfig.load_files(
          Rails.root.join("config", "settings.yml").to_s,
          Rails.root.join("config", "settings", "#{Rails.env}.yml").to_s,
          Rails.root.join("config", "environments", "#{Rails.env}.yml").to_s
        )
        
        Kernel.const_set(RailsConfig.const_name, settings)
      end

      # Rails Dev environment should reload the Settings on every request
      if Rails.env.development?
        initializer :rails_config_reload_on_development do
          ActionController::Base.class_eval do
            prepend_before_filter { ::Settings.reload! }
          end
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_config-0.1.5 lib/rails_config/railtie.rb
rails_config-0.1.4 lib/rails_config/railtie.rb
rails_config-0.1.3 lib/rails_config/railtie.rb
rails_config-0.1.0 lib/rails_config/railtie.rb