Sha256: c01525ff376cc69a145b9b41b69e27a36740d453381e7cd2329b944622a997f4

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module Config
  module Integration
    module Rails
      if defined?(::Rails::Railtie)
        class Railtie < ::Rails::Railtie
          # Load rake tasks (eg. Heroku)
          rake_tasks do
            Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
          end

          config.before_configuration { preload }

          def preload
            # Manually load the custom initializer before everything else
            initializer = ::Rails.root.join("config", "initializers", "config.rb")
            require initializer if File.exist?(initializer)

            # Parse the settings before any of the initializers
            Config.load_and_set_settings(
              Config.setting_files(::Rails.root.join("config"), ::Rails.env)
            )
          end

          # Rails Dev environment should reload the Settings on every request
          if ::Rails.env.development?
            initializer :config_reload_on_development do
              ActionController::Base.class_eval do
                if ::Rails::VERSION::MAJOR >= 4
                  prepend_before_action { ::Config.reload! }
                else
                  prepend_before_filter { ::Config.reload! }
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
config-1.2.0 lib/config/integrations/rails/railtie.rb