activesupport 4.0.12 → 7.0.2.4

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