module RailsEnv

Constants

VERSION

Public Class Methods

config() click to toggle source
# File lib/rails-env.rb, line 24
def self.config
  Rails.configuration
end
propagate(options_name, target_name, target_property = nil) click to toggle source
# File lib/rails-env.rb, line 74
def self.propagate(options_name, target_name, target_property = nil)
  return unless Object.const_defined?(target_name)
  return unless config.respond_to?(options_name)

  target = Object.const_get(target_name)
  options = config.public_send(options_name)

  if options.is_a?(Hash)
    options.each do |key, value|
      target.public_send("#{key}=", value) if target.respond_to?("#{key}=")
    end
  else
    target.public_send("#{target_property}=", options)
  end
end
propagate_autoload_paths() click to toggle source
# File lib/rails-env.rb, line 61
def self.propagate_autoload_paths
  all_autoload_paths = (
    config.autoload_paths +
    config.eager_load_paths +
    config.autoload_once_paths
  ).uniq

  ActiveSupport::Dependencies.autoload_paths.unshift(*all_autoload_paths)
  ActiveSupport::Dependencies.autoload_once_paths.unshift(
    *config.autoload_once_paths
  )
end
propagate_cache_store() click to toggle source
# File lib/rails-env.rb, line 41
def self.propagate_cache_store
  Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
end
propagate_configuration!() click to toggle source
# File lib/rails-env.rb, line 28
def self.propagate_configuration!
  propagate(:action_controller, "::ActionController::Base")
  propagate(:action_mailer, "::ActionMailer::Base")
  propagate(:action_view, "::ActionView::Base")
  propagate(:active_job, "::ActiveJob::Base")
  propagate(:active_record, "::ActiveRecord::Base")
  propagate(:time_zone, "::Time", :zone)
  propagate_hosts
  propagate_autoload_paths
  propagate_i18n
  propagate_cache_store
end
propagate_hosts() click to toggle source
# File lib/rails-env.rb, line 45
def self.propagate_hosts
  Rails.application.config.hosts = config.hosts
end
propagate_i18n() click to toggle source
# File lib/rails-env.rb, line 49
def self.propagate_i18n
  I18n.available_locales = (config.i18n.available_locales || [])
                           .compact
                           .map(&:to_sym)
                           .uniq
  if config.i18n.default_locale
    I18n.default_locale = config.i18n.default_locale
  end
  I18n.locale = config.i18n.locale if config.i18n.locale
  I18n.load_path += config.i18n.load_path if config.i18n.load_path
end