diff --git a/lib/dry/schema/messages/yaml.rb b/lib/dry/schema/messages/yaml.rb index 2accc320..e733362c 100644 --- a/lib/dry/schema/messages/yaml.rb +++ b/lib/dry/schema/messages/yaml.rb @@ -70,7 +70,9 @@ def self.flat_hash(hash, path = EMPTY_ARRAY, keys = {}) # @api private def self.cache - @cache ||= Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new } + @cache ||= Concurrent::Map.new do |h, k| + h.compute_if_absent(k) { Concurrent::Map.new } + end end # @api private