Class: Serega::SeregaValidations::Utils::CheckOptIsStringOrSymbol
- Inherits:
-
Object
- Object
- Serega::SeregaValidations::Utils::CheckOptIsStringOrSymbol
- Defined in:
- lib/serega/validations/utils/check_opt_is_string_or_symbol.rb
Overview
Utility to check hash key value is String or Symbol
Class Method Summary collapse
-
.call(opts, key) ⇒ void
Checks hash key has String or Symbol value.
Class Method Details
.call(opts, key) ⇒ void
This method returns an undefined value.
Checks hash key has String or Symbol value
18 19 20 21 22 23 24 25 |
# File 'lib/serega/validations/utils/check_opt_is_string_or_symbol.rb', line 18 def self.call(opts, key) return unless opts.key?(key) value = opts[key] return if value.is_a?(String) || value.is_a?(Symbol) raise SeregaError, "Invalid option #{key.inspect} => #{value.inspect}. Must be a String or a Symbol" end |