aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-24 23:59:29 +0100
committerJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-24 23:59:29 +0100
commit90e9e46576c0a8d57887484cd4f3f51b3b6cce3a (patch)
treede254a8fd31ae36f8b9371c9f0e645c7ed1b727d /activesupport/lib
parent0ece244feec236f57fb2f55ea564409f25475923 (diff)
parent4e96442c4e404141830b2d7f0d850b6556190b39 (diff)
downloadrails-90e9e46576c0a8d57887484cd4f3f51b3b6cce3a.tar.gz
rails-90e9e46576c0a8d57887484cd4f3f51b3b6cce3a.tar.bz2
rails-90e9e46576c0a8d57887484cd4f3f51b3b6cce3a.zip
Merge branch 'master' of github.com:mikel/rails
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/railtie.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb
new file mode 100644
index 0000000000..55608ac1c5
--- /dev/null
+++ b/activesupport/lib/active_support/railtie.rb
@@ -0,0 +1,60 @@
+require "active_support"
+require "rails"
+
+module I18n
+ class Railtie < Rails::Railtie
+ railtie_name :i18n
+
+ # Initialize I18n load paths to an array
+ config.i18n.load_path = []
+
+ initializer :initialize_i18n do
+ require 'active_support/i18n'
+
+ ActionDispatch::Callbacks.to_prepare do
+ I18n.reload!
+ end
+ end
+
+ # Set the i18n configuration from config.i18n but special-case for
+ # 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
+ I18n.load_path += value
+ else
+ I18n.send("#{setting}=", value)
+ end
+ end
+
+ 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