Module: Utils::Data Private

Defined in:
utils/data.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.assert_valid_keys(hash, *valid_keys) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • hash (Hash{T.type_parameter(:Key) => T.type_parameter(:Value)})
  • valid_keys (T.type_parameter(:Key), Array<T.type_parameter(:Key)>)


14
15
16
17
18
19
20
21
22
23
# File 'utils/data.rb', line 14

def assert_valid_keys(hash, *valid_keys)
  valid_keys.flatten!
  hash.each_key do |key|
    next if valid_keys.include?(key)

    Kernel.raise ArgumentError,
                 "Unknown key: #{T.unsafe(key).inspect}. " \
                 "Valid keys are: #{valid_keys.map { |valid_key| T.unsafe(valid_key).inspect }.join(", ")}"
  end
end