lib/rails-env.rb in rails-env-1.0.7 vs lib/rails-env.rb in rails-env-1.0.8

- old
+ new

@@ -1,10 +1,13 @@ +# frozen_string_literal: true + require "rails-env/version" module Rails class << self env_method = instance_method(:env=) + remove_method(:env=) define_method :env= do |env| env_method.bind(self).call(env) Rails.env.extend(RailsEnv::Extension) end @@ -27,25 +30,32 @@ 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 def self.propagate_cache_store Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store) end + def self.propagate_hosts + Rails.application.config.hosts = config.hosts + end + def self.propagate_i18n I18n.available_locales = (config.i18n.available_locales || []) - .compact - .map(&:to_sym) - .uniq - I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale + .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 def self.propagate_autoload_paths @@ -54,10 +64,12 @@ 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) + ActiveSupport::Dependencies.autoload_once_paths.unshift( + *config.autoload_once_paths + ) end def self.propagate(options_name, target_name, target_property = nil) return unless Object.const_defined?(target_name) return unless config.respond_to?(options_name)