diff options
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/railtie.rb | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index 55608ac1c5..a80fa77e1e 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -1,11 +1,39 @@ require "active_support" require "rails" +module ActiveSupport + class Railtie < Rails::Railtie + railtie_name :active_support + + # Loads support for "whiny nil" (noisy warnings when methods are invoked + # on +nil+ values) if Configuration#whiny_nils is true. + initializer :initialize_whiny_nils do |app| + require 'active_support/whiny_nil' if app.config.whiny_nils + end + + # Sets the default value for Time.zone + # If assigned value cannot be matched to a TimeZone, an exception will be raised. + initializer :initialize_time_zone do |app| + require 'active_support/core_ext/time/zones' + zone_default = Time.__send__(:get_zone, app.config.time_zone) + + unless zone_default + raise \ + 'Value assigned to config.time_zone not recognized.' + + 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' + end + + Time.zone_default = zone_default + end + end +end + module I18n class Railtie < Rails::Railtie railtie_name :i18n # Initialize I18n load paths to an array + config.i18n.engines_load_path = [] config.i18n.load_path = [] initializer :initialize_i18n do @@ -20,7 +48,10 @@ module I18n # the load_path which should be appended to what's already set instead of overwritten. config.after_initialize do |app| app.config.i18n.each do |setting, value| - if setting == :load_path + case setting + when :engines_load_path + app.config.i18n.load_path.unshift(*value) + when :load_path I18n.load_path += value else I18n.send("#{setting}=", value) @@ -30,31 +61,4 @@ module I18n I18n.reload! end end -end - -module ActiveSupport - class Railtie < Rails::Railtie - railtie_name :active_support - - # Loads support for "whiny nil" (noisy warnings when methods are invoked - # on +nil+ values) if Configuration#whiny_nils is true. - initializer :initialize_whiny_nils do |app| - require 'active_support/whiny_nil' if app.config.whiny_nils - end - - # Sets the default value for Time.zone - # If assigned value cannot be matched to a TimeZone, an exception will be raised. - initializer :initialize_time_zone do |app| - require 'active_support/core_ext/time/zones' - zone_default = Time.__send__(:get_zone, app.config.time_zone) - - unless zone_default - raise \ - 'Value assigned to config.time_zone not recognized.' + - 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' - end - - Time.zone_default = zone_default - end - end end
\ No newline at end of file |