activesupport 5.1.7 → 7.0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (279) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +259 -585
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +6 -5
  5. data/lib/active_support/actionable_error.rb +48 -0
  6. data/lib/active_support/all.rb +2 -0
  7. data/lib/active_support/array_inquirer.rb +4 -2
  8. data/lib/active_support/backtrace_cleaner.rb +33 -5
  9. data/lib/active_support/benchmarkable.rb +5 -3
  10. data/lib/active_support/builder.rb +2 -0
  11. data/lib/active_support/cache/file_store.rb +50 -43
  12. data/lib/active_support/cache/mem_cache_store.rb +194 -67
  13. data/lib/active_support/cache/memory_store.rb +70 -34
  14. data/lib/active_support/cache/null_store.rb +18 -3
  15. data/lib/active_support/cache/redis_cache_store.rb +474 -0
  16. data/lib/active_support/cache/strategy/local_cache.rb +73 -50
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +2 -0
  18. data/lib/active_support/cache.rb +556 -220
  19. data/lib/active_support/callbacks.rb +264 -159
  20. data/lib/active_support/code_generator.rb +65 -0
  21. data/lib/active_support/concern.rb +81 -8
  22. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +16 -0
  23. data/lib/active_support/concurrency/share_lock.rb +4 -3
  24. data/lib/active_support/configurable.rb +17 -16
  25. data/lib/active_support/configuration_file.rb +51 -0
  26. data/lib/active_support/core_ext/array/access.rb +18 -8
  27. data/lib/active_support/core_ext/array/conversions.rb +20 -17
  28. data/lib/active_support/core_ext/array/deprecated_conversions.rb +25 -0
  29. data/lib/active_support/core_ext/array/extract.rb +21 -0
  30. data/lib/active_support/core_ext/array/extract_options.rb +2 -0
  31. data/lib/active_support/core_ext/array/grouping.rb +8 -6
  32. data/lib/active_support/core_ext/array/inquiry.rb +4 -2
  33. data/lib/active_support/core_ext/array/wrap.rb +2 -0
  34. data/lib/active_support/core_ext/array.rb +4 -1
  35. data/lib/active_support/core_ext/benchmark.rb +4 -2
  36. data/lib/active_support/core_ext/big_decimal/conversions.rb +3 -1
  37. data/lib/active_support/core_ext/big_decimal.rb +2 -0
  38. data/lib/active_support/core_ext/class/attribute.rb +50 -47
  39. data/lib/active_support/core_ext/class/attribute_accessors.rb +2 -0
  40. data/lib/active_support/core_ext/class/subclasses.rb +10 -24
  41. data/lib/active_support/core_ext/class.rb +2 -0
  42. data/lib/active_support/core_ext/date/acts_like.rb +2 -0
  43. data/lib/active_support/core_ext/date/blank.rb +3 -1
  44. data/lib/active_support/core_ext/date/calculations.rb +17 -14
  45. data/lib/active_support/core_ext/date/conversions.rb +24 -22
  46. data/lib/active_support/core_ext/date/deprecated_conversions.rb +26 -0
  47. data/lib/active_support/core_ext/date/zones.rb +2 -0
  48. data/lib/active_support/core_ext/date.rb +3 -0
  49. data/lib/active_support/core_ext/date_and_time/calculations.rb +65 -41
  50. data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -1
  51. data/lib/active_support/core_ext/date_and_time/zones.rb +2 -1
  52. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -0
  53. data/lib/active_support/core_ext/date_time/blank.rb +3 -1
  54. data/lib/active_support/core_ext/date_time/calculations.rb +3 -1
  55. data/lib/active_support/core_ext/date_time/compatibility.rb +7 -5
  56. data/lib/active_support/core_ext/date_time/conversions.rb +15 -14
  57. data/lib/active_support/core_ext/date_time/deprecated_conversions.rb +22 -0
  58. data/lib/active_support/core_ext/date_time.rb +3 -0
  59. data/lib/active_support/core_ext/digest/uuid.rb +42 -14
  60. data/lib/active_support/core_ext/digest.rb +3 -0
  61. data/lib/active_support/core_ext/enumerable.rb +244 -72
  62. data/lib/active_support/core_ext/file/atomic.rb +6 -2
  63. data/lib/active_support/core_ext/file.rb +2 -0
  64. data/lib/active_support/core_ext/hash/conversions.rb +7 -6
  65. data/lib/active_support/core_ext/hash/deep_merge.rb +8 -12
  66. data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
  67. data/lib/active_support/core_ext/hash/except.rb +4 -2
  68. data/lib/active_support/core_ext/hash/indifferent_access.rb +5 -3
  69. data/lib/active_support/core_ext/hash/keys.rb +4 -31
  70. data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
  71. data/lib/active_support/core_ext/hash/slice.rb +8 -29
  72. data/lib/active_support/core_ext/hash.rb +3 -2
  73. data/lib/active_support/core_ext/integer/inflections.rb +2 -0
  74. data/lib/active_support/core_ext/integer/multiple.rb +3 -1
  75. data/lib/active_support/core_ext/integer/time.rb +7 -14
  76. data/lib/active_support/core_ext/integer.rb +2 -0
  77. data/lib/active_support/core_ext/kernel/concern.rb +2 -0
  78. data/lib/active_support/core_ext/kernel/reporting.rb +6 -4
  79. data/lib/active_support/core_ext/kernel/singleton_class.rb +3 -1
  80. data/lib/active_support/core_ext/kernel.rb +2 -1
  81. data/lib/active_support/core_ext/load_error.rb +3 -8
  82. data/lib/active_support/core_ext/module/aliasing.rb +2 -0
  83. data/lib/active_support/core_ext/module/anonymous.rb +2 -0
  84. data/lib/active_support/core_ext/module/attr_internal.rb +4 -2
  85. data/lib/active_support/core_ext/module/attribute_accessors.rb +46 -56
  86. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +36 -27
  87. data/lib/active_support/core_ext/module/concerning.rb +15 -10
  88. data/lib/active_support/core_ext/module/delegation.rb +97 -58
  89. data/lib/active_support/core_ext/module/deprecation.rb +2 -0
  90. data/lib/active_support/core_ext/module/introspection.rb +18 -15
  91. data/lib/active_support/core_ext/module/redefine_method.rb +40 -0
  92. data/lib/active_support/core_ext/module/remove_method.rb +5 -23
  93. data/lib/active_support/core_ext/module.rb +3 -1
  94. data/lib/active_support/core_ext/name_error.rb +30 -2
  95. data/lib/active_support/core_ext/numeric/bytes.rb +2 -0
  96. data/lib/active_support/core_ext/numeric/conversions.rb +134 -129
  97. data/lib/active_support/core_ext/numeric/deprecated_conversions.rb +60 -0
  98. data/lib/active_support/core_ext/numeric/time.rb +7 -15
  99. data/lib/active_support/core_ext/numeric.rb +3 -1
  100. data/lib/active_support/core_ext/object/acts_like.rb +41 -6
  101. data/lib/active_support/core_ext/object/blank.rb +15 -5
  102. data/lib/active_support/core_ext/object/conversions.rb +2 -0
  103. data/lib/active_support/core_ext/object/deep_dup.rb +3 -1
  104. data/lib/active_support/core_ext/object/duplicable.rb +16 -110
  105. data/lib/active_support/core_ext/object/inclusion.rb +2 -0
  106. data/lib/active_support/core_ext/object/instance_variables.rb +2 -0
  107. data/lib/active_support/core_ext/object/json.rb +51 -26
  108. data/lib/active_support/core_ext/object/to_param.rb +2 -0
  109. data/lib/active_support/core_ext/object/to_query.rb +4 -2
  110. data/lib/active_support/core_ext/object/try.rb +26 -14
  111. data/lib/active_support/core_ext/object/with_options.rb +24 -3
  112. data/lib/active_support/core_ext/object.rb +2 -0
  113. data/lib/active_support/core_ext/pathname/existence.rb +21 -0
  114. data/lib/active_support/core_ext/pathname.rb +3 -0
  115. data/lib/active_support/core_ext/range/compare_range.rb +57 -0
  116. data/lib/active_support/core_ext/range/conversions.rb +35 -25
  117. data/lib/active_support/core_ext/range/deprecated_conversions.rb +26 -0
  118. data/lib/active_support/core_ext/range/each.rb +6 -3
  119. data/lib/active_support/core_ext/range/include_time_with_zone.rb +7 -0
  120. data/lib/active_support/core_ext/range/overlaps.rb +3 -1
  121. data/lib/active_support/core_ext/range.rb +4 -1
  122. data/lib/active_support/core_ext/regexp.rb +10 -5
  123. data/lib/active_support/core_ext/securerandom.rb +25 -3
  124. data/lib/active_support/core_ext/string/access.rb +7 -16
  125. data/lib/active_support/core_ext/string/behavior.rb +2 -0
  126. data/lib/active_support/core_ext/string/conversions.rb +5 -2
  127. data/lib/active_support/core_ext/string/exclude.rb +2 -0
  128. data/lib/active_support/core_ext/string/filters.rb +44 -1
  129. data/lib/active_support/core_ext/string/indent.rb +2 -0
  130. data/lib/active_support/core_ext/string/inflections.rb +69 -16
  131. data/lib/active_support/core_ext/string/inquiry.rb +4 -1
  132. data/lib/active_support/core_ext/string/multibyte.rb +9 -4
  133. data/lib/active_support/core_ext/string/output_safety.rb +135 -27
  134. data/lib/active_support/core_ext/string/starts_ends_with.rb +4 -2
  135. data/lib/active_support/core_ext/string/strip.rb +5 -1
  136. data/lib/active_support/core_ext/string/zones.rb +2 -0
  137. data/lib/active_support/core_ext/string.rb +2 -0
  138. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +6 -0
  139. data/lib/active_support/core_ext/symbol.rb +3 -0
  140. data/lib/active_support/core_ext/time/acts_like.rb +2 -0
  141. data/lib/active_support/core_ext/time/calculations.rb +81 -24
  142. data/lib/active_support/core_ext/time/compatibility.rb +4 -2
  143. data/lib/active_support/core_ext/time/conversions.rb +17 -12
  144. data/lib/active_support/core_ext/time/deprecated_conversions.rb +22 -0
  145. data/lib/active_support/core_ext/time/zones.rb +12 -25
  146. data/lib/active_support/core_ext/time.rb +3 -0
  147. data/lib/active_support/core_ext/uri.rb +4 -23
  148. data/lib/active_support/core_ext.rb +4 -1
  149. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  150. data/lib/active_support/current_attributes.rb +226 -0
  151. data/lib/active_support/dependencies/autoload.rb +2 -0
  152. data/lib/active_support/dependencies/interlock.rb +12 -18
  153. data/lib/active_support/dependencies/require_dependency.rb +28 -0
  154. data/lib/active_support/dependencies.rb +59 -715
  155. data/lib/active_support/deprecation/behaviors.rb +48 -13
  156. data/lib/active_support/deprecation/constant_accessor.rb +4 -2
  157. data/lib/active_support/deprecation/disallowed.rb +56 -0
  158. data/lib/active_support/deprecation/instance_delegator.rb +2 -1
  159. data/lib/active_support/deprecation/method_wrappers.rb +29 -21
  160. data/lib/active_support/deprecation/proxy_wrappers.rb +34 -8
  161. data/lib/active_support/deprecation/reporting.rb +54 -9
  162. data/lib/active_support/deprecation.rb +10 -3
  163. data/lib/active_support/descendants_tracker.rb +192 -34
  164. data/lib/active_support/digest.rb +22 -0
  165. data/lib/active_support/duration/iso8601_parser.rb +9 -9
  166. data/lib/active_support/duration/iso8601_serializer.rb +29 -15
  167. data/lib/active_support/duration.rb +158 -72
  168. data/lib/active_support/encrypted_configuration.rb +56 -0
  169. data/lib/active_support/encrypted_file.rb +129 -0
  170. data/lib/active_support/environment_inquirer.rb +20 -0
  171. data/lib/active_support/error_reporter.rb +117 -0
  172. data/lib/active_support/evented_file_update_checker.rb +87 -122
  173. data/lib/active_support/execution_context/test_helper.rb +13 -0
  174. data/lib/active_support/execution_context.rb +53 -0
  175. data/lib/active_support/execution_wrapper.rb +46 -21
  176. data/lib/active_support/executor/test_helper.rb +7 -0
  177. data/lib/active_support/executor.rb +2 -0
  178. data/lib/active_support/file_update_checker.rb +2 -1
  179. data/lib/active_support/fork_tracker.rb +71 -0
  180. data/lib/active_support/gem_version.rb +7 -5
  181. data/lib/active_support/gzip.rb +2 -0
  182. data/lib/active_support/hash_with_indifferent_access.rb +126 -42
  183. data/lib/active_support/html_safe_translation.rb +43 -0
  184. data/lib/active_support/i18n.rb +5 -1
  185. data/lib/active_support/i18n_railtie.rb +19 -14
  186. data/lib/active_support/inflections.rb +2 -0
  187. data/lib/active_support/inflector/inflections.rb +41 -14
  188. data/lib/active_support/inflector/methods.rb +73 -87
  189. data/lib/active_support/inflector/transliterate.rb +56 -18
  190. data/lib/active_support/inflector.rb +2 -0
  191. data/lib/active_support/isolated_execution_state.rb +72 -0
  192. data/lib/active_support/json/decoding.rb +27 -26
  193. data/lib/active_support/json/encoding.rb +16 -6
  194. data/lib/active_support/json.rb +2 -0
  195. data/lib/active_support/key_generator.rb +25 -38
  196. data/lib/active_support/lazy_load_hooks.rb +35 -6
  197. data/lib/active_support/locale/en.rb +33 -0
  198. data/lib/active_support/locale/en.yml +8 -4
  199. data/lib/active_support/log_subscriber/test_helper.rb +4 -2
  200. data/lib/active_support/log_subscriber.rb +54 -13
  201. data/lib/active_support/logger.rb +4 -17
  202. data/lib/active_support/logger_silence.rb +13 -20
  203. data/lib/active_support/logger_thread_safe_level.rb +48 -10
  204. data/lib/active_support/message_encryptor.rb +111 -37
  205. data/lib/active_support/message_verifier.rb +124 -21
  206. data/lib/active_support/messages/metadata.rb +80 -0
  207. data/lib/active_support/messages/rotation_configuration.rb +23 -0
  208. data/lib/active_support/messages/rotator.rb +57 -0
  209. data/lib/active_support/multibyte/chars.rb +19 -76
  210. data/lib/active_support/multibyte/unicode.rb +9 -331
  211. data/lib/active_support/multibyte.rb +3 -1
  212. data/lib/active_support/notifications/fanout.rb +165 -37
  213. data/lib/active_support/notifications/instrumenter.rb +92 -11
  214. data/lib/active_support/notifications.rb +96 -30
  215. data/lib/active_support/number_helper/number_converter.rb +8 -9
  216. data/lib/active_support/number_helper/number_to_currency_converter.rb +14 -12
  217. data/lib/active_support/number_helper/number_to_delimited_converter.rb +6 -3
  218. data/lib/active_support/number_helper/number_to_human_converter.rb +6 -3
  219. data/lib/active_support/number_helper/number_to_human_size_converter.rb +7 -4
  220. data/lib/active_support/number_helper/number_to_percentage_converter.rb +5 -1
  221. data/lib/active_support/number_helper/number_to_phone_converter.rb +6 -3
  222. data/lib/active_support/number_helper/number_to_rounded_converter.rb +14 -27
  223. data/lib/active_support/number_helper/rounding_helper.rb +16 -34
  224. data/lib/active_support/number_helper.rb +38 -12
  225. data/lib/active_support/option_merger.rb +19 -6
  226. data/lib/active_support/ordered_hash.rb +4 -2
  227. data/lib/active_support/ordered_options.rb +18 -6
  228. data/lib/active_support/parameter_filter.rb +138 -0
  229. data/lib/active_support/per_thread_registry.rb +8 -1
  230. data/lib/active_support/proxy_object.rb +2 -0
  231. data/lib/active_support/rails.rb +3 -10
  232. data/lib/active_support/railtie.rb +112 -11
  233. data/lib/active_support/reloader.rb +12 -11
  234. data/lib/active_support/rescuable.rb +19 -18
  235. data/lib/active_support/ruby_features.rb +7 -0
  236. data/lib/active_support/secure_compare_rotator.rb +51 -0
  237. data/lib/active_support/security_utils.rb +26 -15
  238. data/lib/active_support/string_inquirer.rb +4 -3
  239. data/lib/active_support/subscriber.rb +81 -42
  240. data/lib/active_support/tagged_logging.rb +45 -9
  241. data/lib/active_support/test_case.rb +86 -2
  242. data/lib/active_support/testing/assertions.rb +89 -21
  243. data/lib/active_support/testing/autorun.rb +2 -0
  244. data/lib/active_support/testing/constant_lookup.rb +2 -0
  245. data/lib/active_support/testing/declarative.rb +2 -0
  246. data/lib/active_support/testing/deprecation.rb +54 -2
  247. data/lib/active_support/testing/file_fixtures.rb +4 -0
  248. data/lib/active_support/testing/isolation.rb +6 -4
  249. data/lib/active_support/testing/method_call_assertions.rb +34 -5
  250. data/lib/active_support/testing/parallelization/server.rb +82 -0
  251. data/lib/active_support/testing/parallelization/worker.rb +103 -0
  252. data/lib/active_support/testing/parallelization.rb +55 -0
  253. data/lib/active_support/testing/parallelize_executor.rb +76 -0
  254. data/lib/active_support/testing/setup_and_teardown.rb +12 -7
  255. data/lib/active_support/testing/stream.rb +6 -7
  256. data/lib/active_support/testing/tagged_logging.rb +3 -1
  257. data/lib/active_support/testing/time_helpers.rb +91 -15
  258. data/lib/active_support/time.rb +2 -0
  259. data/lib/active_support/time_with_zone.rb +168 -56
  260. data/lib/active_support/values/time_zone.rb +85 -37
  261. data/lib/active_support/version.rb +3 -1
  262. data/lib/active_support/xml_mini/jdom.rb +6 -5
  263. data/lib/active_support/xml_mini/libxml.rb +9 -7
  264. data/lib/active_support/xml_mini/libxmlsax.rb +7 -5
  265. data/lib/active_support/xml_mini/nokogiri.rb +8 -6
  266. data/lib/active_support/xml_mini/nokogirisax.rb +6 -4
  267. data/lib/active_support/xml_mini/rexml.rb +13 -4
  268. data/lib/active_support/xml_mini.rb +10 -15
  269. data/lib/active_support.rb +30 -9
  270. metadata +76 -35
  271. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -7
  272. data/lib/active_support/core_ext/hash/compact.rb +0 -27
  273. data/lib/active_support/core_ext/hash/transform_values.rb +0 -30
  274. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
  275. data/lib/active_support/core_ext/marshal.rb +0 -22
  276. data/lib/active_support/core_ext/module/reachable.rb +0 -8
  277. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -26
  278. data/lib/active_support/core_ext/range/include_range.rb +0 -23
  279. data/lib/active_support/values/unicode_tables.dat +0 -0
@@ -1,754 +1,98 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "set"
2
- require "thread"
3
- require "concurrent/map"
4
- require "pathname"
5
- require "active_support/core_ext/module/aliasing"
6
- require "active_support/core_ext/module/attribute_accessors"
7
- require "active_support/core_ext/module/introspection"
8
- require "active_support/core_ext/module/anonymous"
9
- require "active_support/core_ext/object/blank"
10
- require "active_support/core_ext/kernel/reporting"
11
- require "active_support/core_ext/load_error"
12
- require "active_support/core_ext/name_error"
13
- require "active_support/core_ext/string/starts_ends_with"
14
4
  require "active_support/dependencies/interlock"
15
- require "active_support/inflector"
16
5
 
17
- module ActiveSupport #:nodoc:
18
- module Dependencies #:nodoc:
19
- extend self
6
+ module ActiveSupport # :nodoc:
7
+ module Dependencies # :nodoc:
8
+ require_relative "dependencies/require_dependency"
20
9
 
21
- mattr_accessor :interlock
22
- self.interlock = Interlock.new
10
+ singleton_class.attr_accessor :interlock
11
+ @interlock = Interlock.new
23
12
 
24
13
  # :doc:
25
14
 
26
15
  # Execute the supplied block without interference from any
27
16
  # concurrent loads.
28
- def self.run_interlock
29
- Dependencies.interlock.running { yield }
17
+ def self.run_interlock(&block)
18
+ interlock.running(&block)
30
19
  end
31
20
 
32
21
  # Execute the supplied block while holding an exclusive lock,
33
22
  # preventing any other thread from being inside a #run_interlock
34
23
  # block at the same time.
35
- def self.load_interlock
36
- Dependencies.interlock.loading { yield }
24
+ def self.load_interlock(&block)
25
+ interlock.loading(&block)
37
26
  end
38
27
 
39
28
  # Execute the supplied block while holding an exclusive lock,
40
29
  # preventing any other thread from being inside a #run_interlock
41
30
  # block at the same time.
42
- def self.unload_interlock
43
- Dependencies.interlock.unloading { yield }
31
+ def self.unload_interlock(&block)
32
+ interlock.unloading(&block)
44
33
  end
45
34
 
46
35
  # :nodoc:
47
36
 
48
- # Should we turn on Ruby warnings on the first load of dependent files?
49
- mattr_accessor :warnings_on_first_load
50
- self.warnings_on_first_load = false
51
-
52
- # All files ever loaded.
53
- mattr_accessor :history
54
- self.history = Set.new
55
-
56
- # All files currently loaded.
57
- mattr_accessor :loaded
58
- self.loaded = Set.new
59
-
60
- # Stack of files being loaded.
61
- mattr_accessor :loading
62
- self.loading = []
63
-
64
- # Should we load files or require them?
65
- mattr_accessor :mechanism
66
- self.mechanism = ENV["NO_RELOAD"] ? :require : :load
67
-
68
- # The set of directories from which we may automatically load files. Files
69
- # under these directories will be reloaded on each request in development mode,
70
- # unless the directory also appears in autoload_once_paths.
71
- mattr_accessor :autoload_paths
37
+ # The array of directories from which we autoload and reload, if reloading
38
+ # is enabled. The public interface to push directories to this collection
39
+ # from applications or engines is config.autoload_paths.
40
+ #
41
+ # This collection is allowed to have intersection with autoload_once_paths.
42
+ # Common directories are not reloaded.
43
+ singleton_class.attr_accessor :autoload_paths
72
44
  self.autoload_paths = []
73
45
 
74
- # The set of directories from which automatically loaded constants are loaded
75
- # only once. All directories in this set must also be present in +autoload_paths+.
76
- mattr_accessor :autoload_once_paths
46
+ # The array of directories from which we autoload and never reload, even if
47
+ # reloading is enabled. The public interface to push directories to this
48
+ # collection from applications or engines is config.autoload_once_paths.
49
+ singleton_class.attr_accessor :autoload_once_paths
77
50
  self.autoload_once_paths = []
78
51
 
79
- # An array of qualified constant names that have been loaded. Adding a name
80
- # to this array will cause it to be unloaded the next time Dependencies are
81
- # cleared.
82
- mattr_accessor :autoloaded_constants
83
- self.autoloaded_constants = []
84
-
85
- # An array of constant names that need to be unloaded on every request. Used
86
- # to allow arbitrary constants to be marked for unloading.
87
- mattr_accessor :explicitly_unloadable_constants
88
- self.explicitly_unloadable_constants = []
89
-
90
- # The WatchStack keeps a stack of the modules being watched as files are
91
- # loaded. If a file in the process of being loaded (parent.rb) triggers the
92
- # load of another file (child.rb) the stack will ensure that child.rb
93
- # handles the new constants.
52
+ # This is a private set that collects all eager load paths during bootstrap.
53
+ # Useful for Zeitwerk integration. The public interface to push custom
54
+ # directories to this collection from applications or engines is
55
+ # config.eager_load_paths.
56
+ singleton_class.attr_accessor :_eager_load_paths
57
+ self._eager_load_paths = Set.new
58
+
59
+ # If reloading is enabled, this private set holds autoloaded classes tracked
60
+ # by the descendants tracker. It is populated by an on_load callback in the
61
+ # main autoloader. Used to clear state.
62
+ singleton_class.attr_accessor :_autoloaded_tracked_classes
63
+ self._autoloaded_tracked_classes = Set.new
64
+
65
+ # If reloading is enabled, this private attribute stores the main autoloader
66
+ # of a Rails application. It is `nil` otherwise.
94
67
  #
95
- # If child.rb is being autoloaded, its constants will be added to
96
- # autoloaded_constants. If it was being `require`d, they will be discarded.
97
- #
98
- # This is handled by walking back up the watch stack and adding the constants
99
- # found by child.rb to the list of original constants in parent.rb.
100
- class WatchStack
101
- include Enumerable
102
-
103
- # @watching is a stack of lists of constants being watched. For instance,
104
- # if parent.rb is autoloaded, the stack will look like [[Object]]. If
105
- # parent.rb then requires namespace/child.rb, the stack will look like
106
- # [[Object], [Namespace]].
107
-
108
- def initialize
109
- @watching = []
110
- @stack = Hash.new { |h, k| h[k] = [] }
111
- end
112
-
113
- def each(&block)
114
- @stack.each(&block)
115
- end
116
-
117
- def watching?
118
- !@watching.empty?
119
- end
120
-
121
- # Returns a list of new constants found since the last call to
122
- # <tt>watch_namespaces</tt>.
123
- def new_constants
124
- constants = []
125
-
126
- # Grab the list of namespaces that we're looking for new constants under
127
- @watching.last.each do |namespace|
128
- # Retrieve the constants that were present under the namespace when watch_namespaces
129
- # was originally called
130
- original_constants = @stack[namespace].last
131
-
132
- mod = Inflector.constantize(namespace) if Dependencies.qualified_const_defined?(namespace)
133
- next unless mod.is_a?(Module)
134
-
135
- # Get a list of the constants that were added
136
- new_constants = mod.constants(false) - original_constants
137
-
138
- # @stack[namespace] returns an Array of the constants that are being evaluated
139
- # for that namespace. For instance, if parent.rb requires child.rb, the first
140
- # element of @stack[Object] will be an Array of the constants that were present
141
- # before parent.rb was required. The second element will be an Array of the
142
- # constants that were present before child.rb was required.
143
- @stack[namespace].each do |namespace_constants|
144
- namespace_constants.concat(new_constants)
145
- end
146
-
147
- # Normalize the list of new constants, and add them to the list we will return
148
- new_constants.each do |suffix|
149
- constants << ([namespace, suffix] - ["Object"]).join("::".freeze)
150
- end
151
- end
152
- constants
153
- ensure
154
- # A call to new_constants is always called after a call to watch_namespaces
155
- pop_modules(@watching.pop)
156
- end
157
-
158
- # Add a set of modules to the watch stack, remembering the initial
159
- # constants.
160
- def watch_namespaces(namespaces)
161
- @watching << namespaces.map do |namespace|
162
- module_name = Dependencies.to_constant_name(namespace)
163
- original_constants = Dependencies.qualified_const_defined?(module_name) ?
164
- Inflector.constantize(module_name).constants(false) : []
165
-
166
- @stack[module_name] << original_constants
167
- module_name
168
- end
169
- end
170
-
171
- private
172
- def pop_modules(modules)
173
- modules.each { |mod| @stack[mod].pop }
174
- end
175
- end
176
-
177
- # An internal stack used to record which constants are loaded by any block.
178
- mattr_accessor :constant_watch_stack
179
- self.constant_watch_stack = WatchStack.new
180
-
181
- # Module includes this module.
182
- module ModuleConstMissing #:nodoc:
183
- def self.append_features(base)
184
- base.class_eval do
185
- # Emulate #exclude via an ivar
186
- return if defined?(@_const_missing) && @_const_missing
187
- @_const_missing = instance_method(:const_missing)
188
- remove_method(:const_missing)
189
- end
190
- super
191
- end
192
-
193
- def self.exclude_from(base)
194
- base.class_eval do
195
- define_method :const_missing, @_const_missing
196
- @_const_missing = nil
197
- end
198
- end
199
-
200
- def const_missing(const_name)
201
- from_mod = anonymous? ? guess_for_anonymous(const_name) : self
202
- Dependencies.load_missing_constant(from_mod, const_name)
203
- end
204
-
205
- # We assume that the name of the module reflects the nesting
206
- # (unless it can be proven that is not the case) and the path to the file
207
- # that defines the constant. Anonymous modules cannot follow these
208
- # conventions and therefore we assume that the user wants to refer to a
209
- # top-level constant.
210
- def guess_for_anonymous(const_name)
211
- if Object.const_defined?(const_name)
212
- raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name
213
- else
214
- Object
215
- end
216
- end
217
-
218
- def unloadable(const_desc = self)
219
- super(const_desc)
220
- end
221
- end
222
-
223
- # Object includes this module.
224
- module Loadable #:nodoc:
225
- def self.exclude_from(base)
226
- base.class_eval do
227
- define_method(:load, Kernel.instance_method(:load))
228
- private :load
229
- end
230
- end
231
-
232
- def require_or_load(file_name)
233
- Dependencies.require_or_load(file_name)
234
- end
235
-
236
- # Interprets a file using <tt>mechanism</tt> and marks its defined
237
- # constants as autoloaded. <tt>file_name</tt> can be either a string or
238
- # respond to <tt>to_path</tt>.
239
- #
240
- # Use this method in code that absolutely needs a certain constant to be
241
- # defined at that point. A typical use case is to make constant name
242
- # resolution deterministic for constants with the same relative name in
243
- # different namespaces whose evaluation would depend on load order
244
- # otherwise.
245
- def require_dependency(file_name, message = "No such file to load -- %s.rb")
246
- file_name = file_name.to_path if file_name.respond_to?(:to_path)
247
- unless file_name.is_a?(String)
248
- raise ArgumentError, "the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}"
249
- end
250
-
251
- Dependencies.depend_on(file_name, message)
252
- end
253
-
254
- def load_dependency(file)
255
- if Dependencies.load? && Dependencies.constant_watch_stack.watching?
256
- Dependencies.new_constants_in(Object) { yield }
257
- else
258
- yield
259
- end
260
- rescue Exception => exception # errors from loading file
261
- exception.blame_file! file if exception.respond_to? :blame_file!
262
- raise
263
- end
264
-
265
- # Mark the given constant as unloadable. Unloadable constants are removed
266
- # each time dependencies are cleared.
267
- #
268
- # Note that marking a constant for unloading need only be done once. Setup
269
- # or init scripts may list each unloadable constant that may need unloading;
270
- # each constant will be removed for every subsequent clear, as opposed to
271
- # for the first clear.
272
- #
273
- # The provided constant descriptor may be a (non-anonymous) module or class,
274
- # or a qualified constant name as a string or symbol.
275
- #
276
- # Returns +true+ if the constant was not previously marked for unloading,
277
- # +false+ otherwise.
278
- def unloadable(const_desc)
279
- Dependencies.mark_for_unload const_desc
280
- end
281
-
282
- private
283
-
284
- def load(file, wrap = false)
285
- result = false
286
- load_dependency(file) { result = super }
287
- result
288
- end
289
-
290
- def require(file)
291
- result = false
292
- load_dependency(file) { result = super }
293
- result
294
- end
295
- end
296
-
297
- # Exception file-blaming.
298
- module Blamable #:nodoc:
299
- def blame_file!(file)
300
- (@blamed_files ||= []).unshift file
301
- end
302
-
303
- def blamed_files
304
- @blamed_files ||= []
305
- end
306
-
307
- def describe_blame
308
- return nil if blamed_files.empty?
309
- "This error occurred while loading the following files:\n #{blamed_files.join "\n "}"
310
- end
311
-
312
- def copy_blame!(exc)
313
- @blamed_files = exc.blamed_files.clone
314
- self
315
- end
316
- end
317
-
318
- def hook!
319
- Object.class_eval { include Loadable }
320
- Module.class_eval { include ModuleConstMissing }
321
- Exception.class_eval { include Blamable }
322
- end
323
-
324
- def unhook!
325
- ModuleConstMissing.exclude_from(Module)
326
- Loadable.exclude_from(Object)
327
- end
328
-
329
- def load?
330
- mechanism == :load
331
- end
332
-
333
- def depend_on(file_name, message = "No such file to load -- %s.rb")
334
- path = search_for_file(file_name)
335
- require_or_load(path || file_name)
336
- rescue LoadError => load_error
337
- if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
338
- load_error.message.replace(message % file_name)
339
- load_error.copy_blame!(load_error)
340
- end
341
- raise
342
- end
343
-
344
- def clear
345
- Dependencies.unload_interlock do
346
- loaded.clear
347
- loading.clear
348
- remove_unloadable_constants!
349
- end
350
- end
351
-
352
- def require_or_load(file_name, const_path = nil)
353
- file_name = $` if file_name =~ /\.rb\z/
354
- expanded = File.expand_path(file_name)
355
- return if loaded.include?(expanded)
356
-
357
- Dependencies.load_interlock do
358
- # Maybe it got loaded while we were waiting for our lock:
359
- return if loaded.include?(expanded)
360
-
361
- # Record that we've seen this file *before* loading it to avoid an
362
- # infinite loop with mutual dependencies.
363
- loaded << expanded
364
- loading << expanded
365
-
366
- begin
367
- if load?
368
- # Enable warnings if this file has not been loaded before and
369
- # warnings_on_first_load is set.
370
- load_args = ["#{file_name}.rb"]
371
- load_args << const_path unless const_path.nil?
372
-
373
- if !warnings_on_first_load || history.include?(expanded)
374
- result = load_file(*load_args)
375
- else
376
- enable_warnings { result = load_file(*load_args) }
377
- end
378
- else
379
- result = require file_name
380
- end
381
- rescue Exception
382
- loaded.delete expanded
383
- raise
384
- ensure
385
- loading.pop
386
- end
387
-
388
- # Record history *after* loading so first load gets warnings.
389
- history << expanded
390
- result
391
- end
392
- end
68
+ # The public interface for this autoloader is `Rails.autoloaders.main`.
69
+ singleton_class.attr_accessor :autoloader
393
70
 
394
- # Is the provided constant path defined?
395
- def qualified_const_defined?(path)
396
- Object.const_defined?(path, false)
397
- end
398
-
399
- # Given +path+, a filesystem path to a ruby file, return an array of
400
- # constant paths which would cause Dependencies to attempt to load this
401
- # file.
402
- def loadable_constants_for_path(path, bases = autoload_paths)
403
- path = $` if path =~ /\.rb\z/
404
- expanded_path = File.expand_path(path)
405
- paths = []
406
-
407
- bases.each do |root|
408
- expanded_root = File.expand_path(root)
409
- next unless expanded_path.start_with?(expanded_root)
410
-
411
- root_size = expanded_root.size
412
- next if expanded_path[root_size] != ?/.freeze
413
-
414
- nesting = expanded_path[(root_size + 1)..-1]
415
- paths << nesting.camelize unless nesting.blank?
416
- end
417
-
418
- paths.uniq!
419
- paths
420
- end
421
-
422
- # Search for a file in autoload_paths matching the provided suffix.
423
- def search_for_file(path_suffix)
424
- path_suffix = path_suffix.sub(/(\.rb)?$/, ".rb".freeze)
425
-
426
- autoload_paths.each do |root|
427
- path = File.join(root, path_suffix)
428
- return path if File.file? path
429
- end
430
- nil # Gee, I sure wish we had first_match ;-)
431
- end
432
-
433
- # Does the provided path_suffix correspond to an autoloadable module?
434
- # Instead of returning a boolean, the autoload base for this module is
435
- # returned.
436
- def autoloadable_module?(path_suffix)
437
- autoload_paths.each do |load_path|
438
- return load_path if File.directory? File.join(load_path, path_suffix)
439
- end
440
- nil
441
- end
442
-
443
- def load_once_path?(path)
444
- # to_s works around a ruby issue where String#starts_with?(Pathname)
445
- # will raise a TypeError: no implicit conversion of Pathname into String
446
- autoload_once_paths.any? { |base| path.starts_with? base.to_s }
447
- end
448
-
449
- # Attempt to autoload the provided module name by searching for a directory
450
- # matching the expected path suffix. If found, the module is created and
451
- # assigned to +into+'s constants with the name +const_name+. Provided that
452
- # the directory was loaded from a reloadable base path, it is added to the
453
- # set of constants that are to be unloaded.
454
- def autoload_module!(into, const_name, qualified_name, path_suffix)
455
- return nil unless base_path = autoloadable_module?(path_suffix)
456
- mod = Module.new
457
- into.const_set const_name, mod
458
- autoloaded_constants << qualified_name unless autoload_once_paths.include?(base_path)
459
- autoloaded_constants.uniq!
460
- mod
461
- end
462
-
463
- # Load the file at the provided path. +const_paths+ is a set of qualified
464
- # constant names. When loading the file, Dependencies will watch for the
465
- # addition of these constants. Each that is defined will be marked as
466
- # autoloaded, and will be removed when Dependencies.clear is next called.
467
- #
468
- # If the second parameter is left off, then Dependencies will construct a
469
- # set of names that the file at +path+ may define. See
470
- # +loadable_constants_for_path+ for more details.
471
- def load_file(path, const_paths = loadable_constants_for_path(path))
472
- const_paths = [const_paths].compact unless const_paths.is_a? Array
473
- parent_paths = const_paths.collect { |const_path| const_path[/.*(?=::)/] || ::Object }
474
-
475
- result = nil
476
- newly_defined_paths = new_constants_in(*parent_paths) do
477
- result = Kernel.load path
478
- end
479
-
480
- autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
481
- autoloaded_constants.uniq!
482
- result
483
- end
484
-
485
- # Returns the constant path for the provided parent and constant name.
486
- def qualified_name_for(mod, name)
487
- mod_name = to_constant_name mod
488
- mod_name == "Object" ? name.to_s : "#{mod_name}::#{name}"
489
- end
490
-
491
- # Load the constant named +const_name+ which is missing from +from_mod+. If
492
- # it is not possible to load the constant into from_mod, try its parent
493
- # module using +const_missing+.
494
- def load_missing_constant(from_mod, const_name)
495
- unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).equal?(from_mod)
496
- raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
497
- end
498
-
499
- qualified_name = qualified_name_for from_mod, const_name
500
- path_suffix = qualified_name.underscore
501
-
502
- file_path = search_for_file(path_suffix)
503
-
504
- if file_path
505
- expanded = File.expand_path(file_path)
506
- expanded.sub!(/\.rb\z/, "".freeze)
507
-
508
- if loading.include?(expanded)
509
- raise "Circular dependency detected while autoloading constant #{qualified_name}"
510
- else
511
- require_or_load(expanded, qualified_name)
512
- raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false)
513
- return from_mod.const_get(const_name)
514
- end
515
- elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
516
- return mod
517
- elsif (parent = from_mod.parent) && parent != from_mod &&
518
- ! from_mod.parents.any? { |p| p.const_defined?(const_name, false) }
519
- # If our parents do not have a constant named +const_name+ then we are free
520
- # to attempt to load upwards. If they do have such a constant, then this
521
- # const_missing must be due to from_mod::const_name, which should not
522
- # return constants from from_mod's parents.
523
- begin
524
- # Since Ruby does not pass the nesting at the point the unknown
525
- # constant triggered the callback we cannot fully emulate constant
526
- # name lookup and need to make a trade-off: we are going to assume
527
- # that the nesting in the body of Foo::Bar is [Foo::Bar, Foo] even
528
- # though it might not be. Counterexamples are
529
- #
530
- # class Foo::Bar
531
- # Module.nesting # => [Foo::Bar]
532
- # end
533
- #
534
- # or
535
- #
536
- # module M::N
537
- # module S::T
538
- # Module.nesting # => [S::T, M::N]
539
- # end
540
- # end
541
- #
542
- # for example.
543
- return parent.const_missing(const_name)
544
- rescue NameError => e
545
- raise unless e.missing_name? qualified_name_for(parent, const_name)
546
- end
547
- end
548
-
549
- name_error = NameError.new("uninitialized constant #{qualified_name}", const_name)
550
- name_error.set_backtrace(caller.reject { |l| l.starts_with? __FILE__ })
551
- raise name_error
552
- end
553
-
554
- # Remove the constants that have been autoloaded, and those that have been
555
- # marked for unloading. Before each constant is removed a callback is sent
556
- # to its class/module if it implements +before_remove_const+.
557
- #
558
- # The callback implementation should be restricted to cleaning up caches, etc.
559
- # as the environment will be in an inconsistent state, e.g. other constants
560
- # may have already been unloaded and not accessible.
561
- def remove_unloadable_constants!
562
- autoloaded_constants.each { |const| remove_constant const }
563
- autoloaded_constants.clear
564
- Reference.clear!
565
- explicitly_unloadable_constants.each { |const| remove_constant const }
566
- end
567
-
568
- class ClassCache
569
- def initialize
570
- @store = Concurrent::Map.new
571
- end
572
-
573
- def empty?
574
- @store.empty?
575
- end
576
-
577
- def key?(key)
578
- @store.key?(key)
579
- end
580
-
581
- def get(key)
582
- key = key.name if key.respond_to?(:name)
583
- @store[key] ||= Inflector.constantize(key)
584
- end
585
- alias :[] :get
586
-
587
- def safe_get(key)
588
- key = key.name if key.respond_to?(:name)
589
- @store[key] ||= Inflector.safe_constantize(key)
590
- end
591
-
592
- def store(klass)
593
- return self unless klass.respond_to?(:name)
594
- raise(ArgumentError, "anonymous classes cannot be cached") if klass.name.empty?
595
- @store[klass.name] = klass
596
- self
597
- end
598
-
599
- def clear!
600
- @store.clear
601
- end
602
- end
603
-
604
- Reference = ClassCache.new
605
-
606
- # Store a reference to a class +klass+.
607
- def reference(klass)
608
- Reference.store klass
609
- end
610
-
611
- # Get the reference for class named +name+.
612
- # Raises an exception if referenced class does not exist.
613
- def constantize(name)
614
- Reference.get(name)
615
- end
616
-
617
- # Get the reference for class named +name+ if one exists.
618
- # Otherwise returns +nil+.
619
- def safe_constantize(name)
620
- Reference.safe_get(name)
621
- end
622
-
623
- # Determine if the given constant has been automatically loaded.
624
- def autoloaded?(desc)
625
- return false if desc.is_a?(Module) && desc.anonymous?
626
- name = to_constant_name desc
627
- return false unless qualified_const_defined?(name)
628
- return autoloaded_constants.include?(name)
629
- end
630
-
631
- # Will the provided constant descriptor be unloaded?
632
- def will_unload?(const_desc)
633
- autoloaded?(const_desc) ||
634
- explicitly_unloadable_constants.include?(to_constant_name(const_desc))
635
- end
636
-
637
- # Mark the provided constant name for unloading. This constant will be
638
- # unloaded on each request, not just the next one.
639
- def mark_for_unload(const_desc)
640
- name = to_constant_name const_desc
641
- if explicitly_unloadable_constants.include? name
642
- false
643
- else
644
- explicitly_unloadable_constants << name
645
- true
646
- end
647
- end
648
-
649
- # Run the provided block and detect the new constants that were loaded during
650
- # its execution. Constants may only be regarded as 'new' once -- so if the
651
- # block calls +new_constants_in+ again, then the constants defined within the
652
- # inner call will not be reported in this one.
71
+ # Private method that reloads constants autoloaded by the main autoloader.
653
72
  #
654
- # If the provided block does not run to completion, and instead raises an
655
- # exception, any new constants are regarded as being only partially defined
656
- # and will be removed immediately.
657
- def new_constants_in(*descs)
658
- constant_watch_stack.watch_namespaces(descs)
659
- success = false
660
-
661
- begin
662
- yield # Now yield to the code that is to define new constants.
663
- success = true
664
- ensure
665
- new_constants = constant_watch_stack.new_constants
666
-
667
- return new_constants if success
668
-
669
- # Remove partially loaded constants.
670
- new_constants.each { |c| remove_constant(c) }
73
+ # Rails.application.reloader.reload! is the public interface for application
74
+ # reload. That involves more things, like deleting unloaded classes from the
75
+ # internal state of the descendants tracker, or reloading routes.
76
+ def self.clear
77
+ unload_interlock do
78
+ _autoloaded_tracked_classes.clear
79
+ autoloader.reload
671
80
  end
672
81
  end
673
82
 
674
- # Convert the provided const desc to a qualified constant name (as a string).
675
- # A module, class, symbol, or string may be provided.
676
- def to_constant_name(desc) #:nodoc:
677
- case desc
678
- when String then desc.sub(/^::/, "")
679
- when Symbol then desc.to_s
680
- when Module
681
- desc.name ||
682
- raise(ArgumentError, "Anonymous modules have no name to be referenced by")
683
- else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
83
+ # Private method used by require_dependency.
84
+ def self.search_for_file(relpath)
85
+ relpath += ".rb" unless relpath.end_with?(".rb")
86
+ autoload_paths.each do |autoload_path|
87
+ abspath = File.join(autoload_path, relpath)
88
+ return abspath if File.file?(abspath)
684
89
  end
90
+ nil
685
91
  end
686
92
 
687
- def remove_constant(const) #:nodoc:
688
- # Normalize ::Foo, ::Object::Foo, Object::Foo, Object::Object::Foo, etc. as Foo.
689
- normalized = const.to_s.sub(/\A::/, "")
690
- normalized.sub!(/\A(Object::)+/, "")
691
-
692
- constants = normalized.split("::")
693
- to_remove = constants.pop
694
-
695
- # Remove the file path from the loaded list.
696
- file_path = search_for_file(const.underscore)
697
- if file_path
698
- expanded = File.expand_path(file_path)
699
- expanded.sub!(/\.rb\z/, "")
700
- loaded.delete(expanded)
701
- end
702
-
703
- if constants.empty?
704
- parent = Object
705
- else
706
- # This method is robust to non-reachable constants.
707
- #
708
- # Non-reachable constants may be passed if some of the parents were
709
- # autoloaded and already removed. It is easier to do a sanity check
710
- # here than require the caller to be clever. We check the parent
711
- # rather than the very const argument because we do not want to
712
- # trigger Kernel#autoloads, see the comment below.
713
- parent_name = constants.join("::")
714
- return unless qualified_const_defined?(parent_name)
715
- parent = constantize(parent_name)
716
- end
717
-
718
- # In an autoloaded user.rb like this
719
- #
720
- # autoload :Foo, 'foo'
721
- #
722
- # class User < ActiveRecord::Base
723
- # end
724
- #
725
- # we correctly register "Foo" as being autoloaded. But if the app does
726
- # not use the "Foo" constant we need to be careful not to trigger
727
- # loading "foo.rb" ourselves. While #const_defined? and #const_get? do
728
- # require the file, #autoload? and #remove_const don't.
729
- #
730
- # We are going to remove the constant nonetheless ---which exists as
731
- # far as Ruby is concerned--- because if the user removes the macro
732
- # call from a class or module that were not autoloaded, as in the
733
- # example above with Object, accessing to that constant must err.
734
- unless parent.autoload?(to_remove)
735
- begin
736
- constantized = parent.const_get(to_remove, false)
737
- rescue NameError
738
- # The constant is no longer reachable, just skip it.
739
- return
740
- else
741
- constantized.before_remove_const if constantized.respond_to?(:before_remove_const)
742
- end
743
- end
744
-
745
- begin
746
- parent.instance_eval { remove_const to_remove }
747
- rescue NameError
748
- # The constant is no longer reachable, just skip it.
749
- end
93
+ # Private method that helps configuring the autoloaders.
94
+ def self.eager_load?(path)
95
+ _eager_load_paths.member?(path)
750
96
  end
751
97
  end
752
98
  end
753
-
754
- ActiveSupport::Dependencies.hook!