Class: Serega::SeregaValidations::Utils::CheckOptIsHash

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

Overview

Utility to check hash key value is Hash

Class Method Summary collapse

Class Method Details

.call(opts, key) ⇒ void

This method returns an undefined value.

Checks hash key value is Hash

Parameters:

  • opts (Hash)

    Some options Hash

  • key (Object)

    Hash key

Raises:



18
19
20
21
22
23
24
25
# File 'lib/serega/validations/utils/check_opt_is_hash.rb', line 18

def self.call(opts, key)
  return unless opts.key?(key)

  value = opts[key]
  return if value.is_a?(Hash)

  raise SeregaError, "Invalid option #{key.inspect} => #{value.inspect}. Must have a Hash value"
end