lib/rails-env.rb in rails-env-1.0.5 vs lib/rails-env.rb in rails-env-1.0.6
- old
+ new
@@ -27,10 +27,11 @@
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_autoload_paths
propagate_i18n
end
def self.propagate_i18n
I18n.available_locales = (config.i18n.available_locales || [])
@@ -40,17 +41,28 @@
I18n.default_locale = config.i18n.default_locale if config.i18n.default_locale
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
+ 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
+
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?(Enumerable)
+ 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)