Class: Serega::SeregaValidations::SeregaUtils::CheckOptIsBool

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

Class Method Summary collapse

Class Method Details

.call(opts, key) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
# File 'lib/serega/validations/utils/check_opt_is_bool.rb', line 7

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

  value = opts[key]
  return if value.equal?(true) || value.equal?(false)

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