2017-07-09 08:06:36 -04:00
|
|
|
# frozen_string_literal: true
|
2014-05-27 13:39:24 -04:00
|
|
|
require "active_support"
|
2017-06-30 01:00:04 -04:00
|
|
|
require_relative "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
|
|
|
|
|
2017-06-02 15:51:10 -04:00
|
|
|
initializer "active_support.set_authenticated_message_encryption" do |app|
|
|
|
|
if app.config.active_support.respond_to?(:use_authenticated_message_encryption)
|
|
|
|
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption =
|
|
|
|
app.config.active_support.use_authenticated_message_encryption
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-26 14:00:27 -04:00
|
|
|
initializer "active_support.reset_all_current_attributes_instances" do |app|
|
2017-05-28 04:47:17 -04:00
|
|
|
app.reloader.before_class_unload { ActiveSupport::CurrentAttributes.clear_all }
|
|
|
|
app.executor.to_run { ActiveSupport::CurrentAttributes.reset_all }
|
|
|
|
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
2017-05-26 14:00:27 -04:00
|
|
|
end
|
|
|
|
|
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|
|
2015-03-02 16:08:47 -05:00
|
|
|
begin
|
|
|
|
TZInfo::DataSource.get
|
|
|
|
rescue TZInfo::DataSourceNotFound => e
|
|
|
|
raise e.exception "tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install"
|
|
|
|
end
|
2017-06-30 01:00:04 -04:00
|
|
|
require_relative "core_ext/time/zones"
|
2017-06-07 19:43:27 -04:00
|
|
|
Time.zone_default = Time.find_zone!(app.config.time_zone)
|
2013-01-22 06:29:20 -05:00
|
|
|
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|
|
2017-06-30 01:00:04 -04:00
|
|
|
require_relative "core_ext/date/calculations"
|
2012-09-18 10:18:19 -04:00
|
|
|
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
|