activesupport 6.1.7.2 → 7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +866 -411
- data/MIT-LICENSE +1 -1
- data/README.rdoc +6 -6
- data/lib/active_support/actionable_error.rb +4 -2
- data/lib/active_support/array_inquirer.rb +2 -2
- data/lib/active_support/backtrace_cleaner.rb +27 -7
- data/lib/active_support/benchmarkable.rb +3 -2
- data/lib/active_support/broadcast_logger.rb +250 -0
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache/coder.rb +153 -0
- data/lib/active_support/cache/entry.rb +134 -0
- data/lib/active_support/cache/file_store.rb +52 -19
- data/lib/active_support/cache/mem_cache_store.rb +195 -60
- data/lib/active_support/cache/memory_store.rb +86 -24
- data/lib/active_support/cache/null_store.rb +16 -2
- data/lib/active_support/cache/redis_cache_store.rb +186 -193
- data/lib/active_support/cache/serializer_with_fallback.rb +175 -0
- data/lib/active_support/cache/strategy/local_cache.rb +63 -71
- data/lib/active_support/cache.rb +478 -247
- data/lib/active_support/callbacks.rb +227 -105
- data/lib/active_support/code_generator.rb +65 -0
- data/lib/active_support/concern.rb +9 -7
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +44 -7
- data/lib/active_support/concurrency/null_lock.rb +13 -0
- data/lib/active_support/concurrency/share_lock.rb +2 -2
- data/lib/active_support/configurable.rb +18 -5
- data/lib/active_support/configuration_file.rb +1 -1
- data/lib/active_support/core_ext/array/access.rb +1 -5
- data/lib/active_support/core_ext/array/conversions.rb +15 -13
- data/lib/active_support/core_ext/array/grouping.rb +6 -6
- data/lib/active_support/core_ext/array/inquiry.rb +2 -2
- data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
- data/lib/active_support/core_ext/class/subclasses.rb +37 -26
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +24 -9
- data/lib/active_support/core_ext/date/conversions.rb +16 -15
- data/lib/active_support/core_ext/date_and_time/calculations.rb +14 -4
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +4 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +19 -15
- data/lib/active_support/core_ext/digest/uuid.rb +30 -14
- data/lib/active_support/core_ext/enumerable.rb +85 -83
- data/lib/active_support/core_ext/erb/util.rb +196 -0
- data/lib/active_support/core_ext/file/atomic.rb +3 -1
- data/lib/active_support/core_ext/hash/conversions.rb +1 -2
- data/lib/active_support/core_ext/hash/deep_merge.rb +22 -14
- data/lib/active_support/core_ext/hash/deep_transform_values.rb +3 -3
- data/lib/active_support/core_ext/hash/indifferent_access.rb +3 -3
- data/lib/active_support/core_ext/hash/keys.rb +4 -4
- data/lib/active_support/core_ext/integer/inflections.rb +12 -12
- data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
- data/lib/active_support/core_ext/kernel/singleton_class.rb +1 -1
- data/lib/active_support/core_ext/module/attribute_accessors.rb +8 -0
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +49 -22
- data/lib/active_support/core_ext/module/concerning.rb +6 -6
- data/lib/active_support/core_ext/module/delegation.rb +41 -18
- data/lib/active_support/core_ext/module/deprecation.rb +15 -12
- data/lib/active_support/core_ext/module/introspection.rb +0 -1
- data/lib/active_support/core_ext/name_error.rb +2 -8
- data/lib/active_support/core_ext/numeric/bytes.rb +9 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +82 -77
- data/lib/active_support/core_ext/object/acts_like.rb +29 -5
- data/lib/active_support/core_ext/object/blank.rb +2 -2
- data/lib/active_support/core_ext/object/deep_dup.rb +17 -1
- data/lib/active_support/core_ext/object/duplicable.rb +15 -4
- data/lib/active_support/core_ext/object/inclusion.rb +13 -5
- data/lib/active_support/core_ext/object/instance_variables.rb +22 -12
- data/lib/active_support/core_ext/object/json.rb +40 -27
- data/lib/active_support/core_ext/object/to_query.rb +2 -4
- data/lib/active_support/core_ext/object/try.rb +20 -20
- data/lib/active_support/core_ext/object/with.rb +44 -0
- data/lib/active_support/core_ext/object/with_options.rb +25 -6
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/pathname/blank.rb +16 -0
- data/lib/active_support/core_ext/pathname/existence.rb +23 -0
- data/lib/active_support/core_ext/pathname.rb +4 -0
- data/lib/active_support/core_ext/range/compare_range.rb +0 -25
- data/lib/active_support/core_ext/range/conversions.rb +34 -13
- data/lib/active_support/core_ext/range/each.rb +1 -1
- data/lib/active_support/core_ext/range/overlap.rb +40 -0
- data/lib/active_support/core_ext/range.rb +1 -2
- data/lib/active_support/core_ext/securerandom.rb +25 -13
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +21 -15
- data/lib/active_support/core_ext/string/indent.rb +1 -1
- data/lib/active_support/core_ext/string/inflections.rb +17 -10
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +85 -193
- data/lib/active_support/core_ext/symbol/starts_ends_with.rb +0 -8
- data/lib/active_support/core_ext/thread/backtrace/location.rb +12 -0
- data/lib/active_support/core_ext/time/calculations.rb +29 -10
- data/lib/active_support/core_ext/time/conversions.rb +14 -13
- data/lib/active_support/core_ext/time/zones.rb +12 -28
- data/lib/active_support/core_ext.rb +1 -0
- data/lib/active_support/current_attributes.rb +46 -21
- data/lib/active_support/deep_mergeable.rb +53 -0
- data/lib/active_support/dependencies/autoload.rb +17 -12
- data/lib/active_support/dependencies/interlock.rb +10 -18
- data/lib/active_support/dependencies/require_dependency.rb +28 -0
- data/lib/active_support/dependencies.rb +58 -788
- data/lib/active_support/deprecation/behaviors.rb +66 -40
- data/lib/active_support/deprecation/constant_accessor.rb +5 -4
- data/lib/active_support/deprecation/deprecators.rb +104 -0
- data/lib/active_support/deprecation/disallowed.rb +6 -8
- data/lib/active_support/deprecation/instance_delegator.rb +31 -4
- data/lib/active_support/deprecation/method_wrappers.rb +9 -26
- data/lib/active_support/deprecation/proxy_wrappers.rb +38 -23
- data/lib/active_support/deprecation/reporting.rb +42 -25
- data/lib/active_support/deprecation.rb +32 -5
- data/lib/active_support/deprecator.rb +7 -0
- data/lib/active_support/descendants_tracker.rb +150 -72
- data/lib/active_support/digest.rb +4 -4
- data/lib/active_support/duration/iso8601_parser.rb +3 -3
- data/lib/active_support/duration/iso8601_serializer.rb +9 -3
- data/lib/active_support/duration.rb +79 -49
- data/lib/active_support/encrypted_configuration.rb +72 -9
- data/lib/active_support/encrypted_file.rb +29 -13
- data/lib/active_support/environment_inquirer.rb +23 -3
- data/lib/active_support/error_reporter/test_helper.rb +15 -0
- data/lib/active_support/error_reporter.rb +203 -0
- data/lib/active_support/evented_file_update_checker.rb +20 -7
- data/lib/active_support/execution_context/test_helper.rb +13 -0
- data/lib/active_support/execution_context.rb +53 -0
- data/lib/active_support/execution_wrapper.rb +31 -12
- data/lib/active_support/executor/test_helper.rb +7 -0
- data/lib/active_support/file_update_checker.rb +4 -2
- data/lib/active_support/fork_tracker.rb +28 -13
- data/lib/active_support/gem_version.rb +4 -4
- data/lib/active_support/gzip.rb +2 -0
- data/lib/active_support/hash_with_indifferent_access.rb +38 -18
- data/lib/active_support/html_safe_translation.rb +43 -0
- data/lib/active_support/i18n.rb +2 -1
- data/lib/active_support/i18n_railtie.rb +21 -14
- data/lib/active_support/inflector/inflections.rb +25 -7
- data/lib/active_support/inflector/methods.rb +50 -63
- data/lib/active_support/inflector/transliterate.rb +4 -2
- data/lib/active_support/isolated_execution_state.rb +76 -0
- data/lib/active_support/json/decoding.rb +2 -1
- data/lib/active_support/json/encoding.rb +27 -45
- data/lib/active_support/key_generator.rb +31 -6
- data/lib/active_support/lazy_load_hooks.rb +33 -7
- data/lib/active_support/locale/en.yml +3 -1
- data/lib/active_support/log_subscriber/test_helper.rb +2 -2
- data/lib/active_support/log_subscriber.rb +96 -35
- data/lib/active_support/logger.rb +9 -60
- data/lib/active_support/logger_thread_safe_level.rb +11 -34
- data/lib/active_support/message_encryptor.rb +206 -56
- data/lib/active_support/message_encryptors.rb +141 -0
- data/lib/active_support/message_pack/cache_serializer.rb +23 -0
- data/lib/active_support/message_pack/extensions.rb +292 -0
- data/lib/active_support/message_pack/serializer.rb +63 -0
- data/lib/active_support/message_pack.rb +50 -0
- data/lib/active_support/message_verifier.rb +235 -84
- data/lib/active_support/message_verifiers.rb +135 -0
- data/lib/active_support/messages/codec.rb +65 -0
- data/lib/active_support/messages/metadata.rb +112 -46
- data/lib/active_support/messages/rotation_coordinator.rb +93 -0
- data/lib/active_support/messages/rotator.rb +34 -32
- data/lib/active_support/messages/serializer_with_fallback.rb +158 -0
- data/lib/active_support/multibyte/chars.rb +12 -11
- data/lib/active_support/multibyte/unicode.rb +9 -49
- data/lib/active_support/multibyte.rb +1 -1
- data/lib/active_support/notifications/fanout.rb +304 -114
- data/lib/active_support/notifications/instrumenter.rb +109 -35
- data/lib/active_support/notifications.rb +24 -24
- data/lib/active_support/number_helper/number_converter.rb +14 -7
- data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +4 -4
- data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
- data/lib/active_support/number_helper/rounding_helper.rb +1 -5
- data/lib/active_support/number_helper.rb +379 -319
- data/lib/active_support/option_merger.rb +10 -18
- data/lib/active_support/ordered_hash.rb +4 -4
- data/lib/active_support/ordered_options.rb +15 -1
- data/lib/active_support/parameter_filter.rb +104 -80
- data/lib/active_support/proxy_object.rb +2 -0
- data/lib/active_support/railtie.rb +83 -21
- data/lib/active_support/reloader.rb +12 -4
- data/lib/active_support/rescuable.rb +14 -12
- data/lib/active_support/ruby_features.rb +7 -0
- data/lib/active_support/secure_compare_rotator.rb +18 -11
- data/lib/active_support/string_inquirer.rb +3 -3
- data/lib/active_support/subscriber.rb +11 -40
- data/lib/active_support/syntax_error_proxy.rb +70 -0
- data/lib/active_support/tagged_logging.rb +60 -24
- data/lib/active_support/test_case.rb +166 -27
- data/lib/active_support/testing/assertions.rb +60 -14
- data/lib/active_support/testing/autorun.rb +0 -2
- data/lib/active_support/testing/constant_stubbing.rb +32 -0
- data/lib/active_support/testing/deprecation.rb +53 -2
- data/lib/active_support/testing/error_reporter_assertions.rb +107 -0
- data/lib/active_support/testing/isolation.rb +30 -29
- data/lib/active_support/testing/method_call_assertions.rb +24 -11
- data/lib/active_support/testing/parallelization/server.rb +4 -0
- data/lib/active_support/testing/parallelization/worker.rb +3 -0
- data/lib/active_support/testing/parallelization.rb +4 -0
- data/lib/active_support/testing/parallelize_executor.rb +81 -0
- data/lib/active_support/testing/stream.rb +4 -6
- data/lib/active_support/testing/strict_warnings.rb +39 -0
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +49 -16
- data/lib/active_support/time_with_zone.rb +39 -28
- data/lib/active_support/values/time_zone.rb +38 -17
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini/jdom.rb +4 -11
- data/lib/active_support/xml_mini/libxml.rb +5 -5
- data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
- data/lib/active_support/xml_mini/nokogiri.rb +5 -5
- data/lib/active_support/xml_mini/nokogirisax.rb +2 -2
- data/lib/active_support/xml_mini/rexml.rb +2 -2
- data/lib/active_support/xml_mini.rb +7 -6
- data/lib/active_support.rb +28 -1
- metadata +107 -18
- data/lib/active_support/core_ext/marshal.rb +0 -26
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +0 -28
- data/lib/active_support/core_ext/range/overlaps.rb +0 -10
- data/lib/active_support/core_ext/uri.rb +0 -29
- data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -120
- data/lib/active_support/per_thread_registry.rb +0 -61
@@ -5,6 +5,8 @@ require "active_support/core_ext/enumerable"
|
|
5
5
|
require "active_support/core_ext/module/delegation"
|
6
6
|
|
7
7
|
module ActiveSupport
|
8
|
+
# = Current Attributes
|
9
|
+
#
|
8
10
|
# Abstract super class that provides a thread-isolated attributes singleton, which resets automatically
|
9
11
|
# before and after each request. This allows you to keep all the per-request attributes easily
|
10
12
|
# available to the whole system.
|
@@ -90,6 +92,8 @@ module ActiveSupport
|
|
90
92
|
include ActiveSupport::Callbacks
|
91
93
|
define_callbacks :reset
|
92
94
|
|
95
|
+
INVALID_ATTRIBUTE_NAMES = [:set, :reset, :resets, :instance, :before_reset, :after_reset, :reset_all, :clear_all] # :nodoc:
|
96
|
+
|
93
97
|
class << self
|
94
98
|
# Returns singleton instance for this class in this thread. If none exists, one is created.
|
95
99
|
def instance
|
@@ -98,37 +102,54 @@ module ActiveSupport
|
|
98
102
|
|
99
103
|
# Declares one or more attributes that will be given both class and instance accessor methods.
|
100
104
|
def attribute(*names)
|
101
|
-
|
105
|
+
invalid_attribute_names = names.map(&:to_sym) & INVALID_ATTRIBUTE_NAMES
|
106
|
+
if invalid_attribute_names.any?
|
107
|
+
raise ArgumentError, "Restricted attribute names: #{invalid_attribute_names.join(", ")}"
|
108
|
+
end
|
109
|
+
|
110
|
+
ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |owner|
|
102
111
|
names.each do |name|
|
103
|
-
|
104
|
-
|
112
|
+
owner.define_cached_method(name, namespace: :current_attributes) do |batch|
|
113
|
+
batch <<
|
114
|
+
"def #{name}" <<
|
115
|
+
"attributes[:#{name}]" <<
|
116
|
+
"end"
|
105
117
|
end
|
106
|
-
|
107
|
-
|
108
|
-
|
118
|
+
owner.define_cached_method("#{name}=", namespace: :current_attributes) do |batch|
|
119
|
+
batch <<
|
120
|
+
"def #{name}=(value)" <<
|
121
|
+
"attributes[:#{name}] = value" <<
|
122
|
+
"end"
|
109
123
|
end
|
110
124
|
end
|
111
125
|
end
|
112
126
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
127
|
+
ActiveSupport::CodeGenerator.batch(singleton_class, __FILE__, __LINE__) do |owner|
|
128
|
+
names.each do |name|
|
129
|
+
owner.define_cached_method(name, namespace: :current_attributes_delegation) do |batch|
|
130
|
+
batch <<
|
131
|
+
"def #{name}" <<
|
132
|
+
"instance.#{name}" <<
|
133
|
+
"end"
|
134
|
+
end
|
135
|
+
owner.define_cached_method("#{name}=", namespace: :current_attributes_delegation) do |batch|
|
136
|
+
batch <<
|
137
|
+
"def #{name}=(value)" <<
|
138
|
+
"instance.#{name} = value" <<
|
139
|
+
"end"
|
140
|
+
end
|
120
141
|
end
|
121
142
|
end
|
122
143
|
end
|
123
144
|
|
124
|
-
# Calls this
|
125
|
-
def before_reset(&block)
|
126
|
-
set_callback :reset, :before, &block
|
145
|
+
# Calls this callback before #reset is called on the instance. Used for resetting external collaborators that depend on current values.
|
146
|
+
def before_reset(*methods, &block)
|
147
|
+
set_callback :reset, :before, *methods, &block
|
127
148
|
end
|
128
149
|
|
129
|
-
# Calls this
|
130
|
-
def resets(&block)
|
131
|
-
set_callback :reset, :after, &block
|
150
|
+
# Calls this callback after #reset is called on the instance. Used for resetting external collaborators, like Time.zone.
|
151
|
+
def resets(*methods, &block)
|
152
|
+
set_callback :reset, :after, *methods, &block
|
132
153
|
end
|
133
154
|
alias_method :after_reset, :resets
|
134
155
|
|
@@ -149,7 +170,7 @@ module ActiveSupport
|
|
149
170
|
end
|
150
171
|
|
151
172
|
def current_instances
|
152
|
-
|
173
|
+
IsolatedExecutionState[:current_attributes_instances] ||= {}
|
153
174
|
end
|
154
175
|
|
155
176
|
def current_instances_key
|
@@ -164,7 +185,11 @@ module ActiveSupport
|
|
164
185
|
|
165
186
|
send(name, *args, &block)
|
166
187
|
end
|
167
|
-
ruby2_keywords(:method_missing)
|
188
|
+
ruby2_keywords(:method_missing)
|
189
|
+
|
190
|
+
def respond_to_missing?(name, _)
|
191
|
+
super || instance.respond_to?(name)
|
192
|
+
end
|
168
193
|
end
|
169
194
|
|
170
195
|
attr_accessor :attributes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
# Provides +deep_merge+ and +deep_merge!+ methods. Expects the including class
|
5
|
+
# to provide a <tt>merge!(other, &block)</tt> method.
|
6
|
+
module DeepMergeable # :nodoc:
|
7
|
+
# Returns a new instance with the values from +other+ merged recursively.
|
8
|
+
#
|
9
|
+
# class Hash
|
10
|
+
# include ActiveSupport::DeepMergeable
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# hash_1 = { a: true, b: { c: [1, 2, 3] } }
|
14
|
+
# hash_2 = { a: false, b: { x: [3, 4, 5] } }
|
15
|
+
#
|
16
|
+
# hash_1.deep_merge(hash_2)
|
17
|
+
# # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
18
|
+
#
|
19
|
+
# A block can be provided to merge non-<tt>DeepMergeable</tt> values:
|
20
|
+
#
|
21
|
+
# hash_1 = { a: 100, b: 200, c: { c1: 100 } }
|
22
|
+
# hash_2 = { b: 250, c: { c1: 200 } }
|
23
|
+
#
|
24
|
+
# hash_1.deep_merge(hash_2) do |key, this_val, other_val|
|
25
|
+
# this_val + other_val
|
26
|
+
# end
|
27
|
+
# # => { a: 100, b: 450, c: { c1: 300 } }
|
28
|
+
#
|
29
|
+
def deep_merge(other, &block)
|
30
|
+
dup.deep_merge!(other, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Same as #deep_merge, but modifies +self+.
|
34
|
+
def deep_merge!(other, &block)
|
35
|
+
merge!(other) do |key, this_val, other_val|
|
36
|
+
if this_val.is_a?(DeepMergeable) && this_val.deep_merge?(other_val)
|
37
|
+
this_val.deep_merge(other_val, &block)
|
38
|
+
elsif block_given?
|
39
|
+
block.call(key, this_val, other_val)
|
40
|
+
else
|
41
|
+
other_val
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns true if +other+ can be deep merged into +self+. Classes may
|
47
|
+
# override this method to restrict or expand the domain of deep mergeable
|
48
|
+
# values. Defaults to checking that +other+ is of type +self.class+.
|
49
|
+
def deep_merge?(other)
|
50
|
+
other.is_a?(self.class)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -3,10 +3,12 @@
|
|
3
3
|
require "active_support/inflector/methods"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
|
+
# = Active Support \Autoload
|
7
|
+
#
|
6
8
|
# Autoload and eager load conveniences for your library.
|
7
9
|
#
|
8
10
|
# This module allows you to define autoloads based on
|
9
|
-
# Rails conventions (i.e. no need to define the path
|
11
|
+
# \Rails conventions (i.e. no need to define the path
|
10
12
|
# it is automatically guessed based on the filename)
|
11
13
|
# and also define a set of constants that needs to be
|
12
14
|
# eager loaded:
|
@@ -26,11 +28,14 @@ module ActiveSupport
|
|
26
28
|
# MyLib.eager_load!
|
27
29
|
module Autoload
|
28
30
|
def self.extended(base) # :nodoc:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
if RUBY_VERSION < "3"
|
32
|
+
base.class_eval do
|
33
|
+
@_autoloads = nil
|
34
|
+
@_under_path = nil
|
35
|
+
@_at_path = nil
|
36
|
+
@_eager_autoload = false
|
37
|
+
@_eagerloaded_constants = nil
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
@@ -41,7 +46,8 @@ module ActiveSupport
|
|
41
46
|
end
|
42
47
|
|
43
48
|
if @_eager_autoload
|
44
|
-
@
|
49
|
+
@_eagerloaded_constants ||= []
|
50
|
+
@_eagerloaded_constants << const_name
|
45
51
|
end
|
46
52
|
|
47
53
|
super const_name, path
|
@@ -69,11 +75,10 @@ module ActiveSupport
|
|
69
75
|
end
|
70
76
|
|
71
77
|
def eager_load!
|
72
|
-
@
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
@_autoloads
|
78
|
+
if @_eagerloaded_constants
|
79
|
+
@_eagerloaded_constants.each { |const_name| const_get(const_name) }
|
80
|
+
@_eagerloaded_constants = nil
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|
@@ -2,23 +2,19 @@
|
|
2
2
|
|
3
3
|
require "active_support/concurrency/share_lock"
|
4
4
|
|
5
|
-
module ActiveSupport
|
6
|
-
module Dependencies
|
5
|
+
module ActiveSupport # :nodoc:
|
6
|
+
module Dependencies # :nodoc:
|
7
7
|
class Interlock
|
8
8
|
def initialize # :nodoc:
|
9
9
|
@lock = ActiveSupport::Concurrency::ShareLock.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def loading
|
13
|
-
@lock.exclusive(purpose: :load, compatible: [:load], after_compatible: [:load])
|
14
|
-
yield
|
15
|
-
end
|
12
|
+
def loading(&block)
|
13
|
+
@lock.exclusive(purpose: :load, compatible: [:load], after_compatible: [:load], &block)
|
16
14
|
end
|
17
15
|
|
18
|
-
def unloading
|
19
|
-
@lock.exclusive(purpose: :unload, compatible: [:load, :unload], after_compatible: [:load, :unload])
|
20
|
-
yield
|
21
|
-
end
|
16
|
+
def unloading(&block)
|
17
|
+
@lock.exclusive(purpose: :unload, compatible: [:load, :unload], after_compatible: [:load, :unload], &block)
|
22
18
|
end
|
23
19
|
|
24
20
|
def start_unloading
|
@@ -37,16 +33,12 @@ module ActiveSupport #:nodoc:
|
|
37
33
|
@lock.stop_sharing
|
38
34
|
end
|
39
35
|
|
40
|
-
def running
|
41
|
-
@lock.sharing
|
42
|
-
yield
|
43
|
-
end
|
36
|
+
def running(&block)
|
37
|
+
@lock.sharing(&block)
|
44
38
|
end
|
45
39
|
|
46
|
-
def permit_concurrent_loads
|
47
|
-
@lock.yield_shares(compatible: [:load])
|
48
|
-
yield
|
49
|
-
end
|
40
|
+
def permit_concurrent_loads(&block)
|
41
|
+
@lock.yield_shares(compatible: [:load], &block)
|
50
42
|
end
|
51
43
|
|
52
44
|
def raw_state(&block) # :nodoc:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveSupport::Dependencies::RequireDependency
|
4
|
+
# <b>Warning:</b> This method is obsolete. The semantics of the autoloader
|
5
|
+
# match Ruby's and you do not need to be defensive with load order anymore.
|
6
|
+
# Just refer to classes and modules normally.
|
7
|
+
#
|
8
|
+
# Engines that do not control the mode in which their parent application runs
|
9
|
+
# should call +require_dependency+ where needed in case the runtime mode is
|
10
|
+
# +:classic+.
|
11
|
+
def require_dependency(filename)
|
12
|
+
filename = filename.to_path if filename.respond_to?(:to_path)
|
13
|
+
|
14
|
+
unless filename.is_a?(String)
|
15
|
+
raise ArgumentError, "the file name must be either a String or implement #to_path -- you passed #{filename.inspect}"
|
16
|
+
end
|
17
|
+
|
18
|
+
if abspath = ActiveSupport::Dependencies.search_for_file(filename)
|
19
|
+
require abspath
|
20
|
+
else
|
21
|
+
require filename
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# We could define require_dependency in Object directly, but a module makes
|
26
|
+
# the extension apparent if you list ancestors.
|
27
|
+
Object.prepend(self)
|
28
|
+
end
|