lib/unified_settings/handlers/credentials.rb in unified_settings-0.1.1 vs lib/unified_settings/handlers/credentials.rb in unified_settings-0.1.2
- old
+ new
@@ -35,8 +35,31 @@
val = Rails.application.credentials.dig(*key_arr.map(&:downcase))
return val unless val.nil?
Rails.application.credentials.dig(*key_arr.map(&:upcase))
end
+
+ protected
+
+ def nested_key_exists?(hash, keys)
+ if Rails.gem_version < Gem::Version.new('7.1.0')
+ super
+ else
+ return false if hash.nil?
+
+ # Rails 7.1 adds a key? method and so we need to get the config
+ # out of the credential object so that it can be treated as a hash
+ # https://github.com/rails/rails/blob/v7.1.1/activesupport/lib/active_support/encrypted_file.rb#L58-L60
+ current_level = hash.config
+ keys.each do |key|
+ return false if current_level.nil?
+ return true if current_level.key?(key)
+
+ current_level = current_level[key]
+ end
+
+ false
+ end
+ end
end
end
end