Class: Serega::SeregaValidations::Utils::CheckAllowedKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/validations/utils/check_allowed_keys.rb

Overview

Utility to check all hash keys are allowed

Class Method Summary collapse

Class Method Details

.call(opts, allowed_keys) ⇒ void

This method returns an undefined value.

Checks hash keys are allowed

Parameters:

  • opts (Hash)

    Some options Hash

  • allowed_keys (Array)

    Allowed hash keys

Raises:



21
22
23
24
25
26
27
# File 'lib/serega/validations/utils/check_allowed_keys.rb', line 21

def self.call(opts, allowed_keys)
  opts.each_key do |key|
    next if allowed_keys.include?(key)

    raise SeregaError, "Invalid option #{key.inspect}. Allowed options are: #{allowed_keys.map(&:inspect).join(", ")}"
  end
end