2010-01-22 14:44:29 -05:00
|
|
|
require "active_support"
|
2010-06-20 08:44:38 -04:00
|
|
|
require "active_support/i18n_railtie"
|
2010-01-22 14:44:29 -05:00
|
|
|
|
2010-01-24 19:06:12 -05:00
|
|
|
module ActiveSupport
|
2012-09-17 01:22:18 -04:00
|
|
|
class Railtie < Rails::Railtie # :nodoc:
|
2010-03-26 13:47:55 -04:00
|
|
|
config.active_support = ActiveSupport::OrderedOptions.new
|
2010-01-24 19:06:12 -05:00
|
|
|
|
2012-08-01 14:54:22 -04:00
|
|
|
config.eager_load_namespaces << ActiveSupport
|
|
|
|
|
2010-06-29 15:18:17 -04:00
|
|
|
initializer "active_support.deprecation_behavior" do |app|
|
|
|
|
if deprecation = app.config.active_support.deprecation
|
|
|
|
ActiveSupport::Deprecation.behavior = deprecation
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-22 06:29:20 -05:00
|
|
|
# Sets the default value for Time.zone
|
|
|
|
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
|
|
|
|
initializer "active_support.initialize_time_zone" do |app|
|
|
|
|
require 'active_support/core_ext/time/zones'
|
|
|
|
zone_default = Time.find_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
|
|
|
|
|
2012-09-18 10:18:19 -04:00
|
|
|
# Sets the default week start
|
|
|
|
# If assigned value is not a valid day symbol (e.g. :sunday, :monday, ...), an exception will be raised.
|
|
|
|
initializer "active_support.initialize_beginning_of_week" do |app|
|
|
|
|
require 'active_support/core_ext/date/calculations'
|
|
|
|
beginning_of_week_default = Date.find_beginning_of_week!(app.config.beginning_of_week)
|
|
|
|
|
|
|
|
Date.beginning_of_week_default = beginning_of_week_default
|
|
|
|
end
|
|
|
|
|
2012-05-12 11:54:28 -04:00
|
|
|
initializer "active_support.set_configs" do |app|
|
|
|
|
app.config.active_support.each do |k, v|
|
|
|
|
k = "#{k}="
|
|
|
|
ActiveSupport.send(k, v) if ActiveSupport.respond_to? k
|
|
|
|
end
|
|
|
|
end
|
2010-01-24 19:06:12 -05:00
|
|
|
end
|
2010-06-29 22:50:41 -04:00
|
|
|
end
|