Class: Devtools::Config::TypeCheck
- Inherits:
-
Object
- Object
- Devtools::Config::TypeCheck
- Defined in:
- lib/devtools/config.rb
Overview
Simple named type check representation
Constant Summary collapse
- ERROR_FORMAT =
'%<name>s: Got instance of %<got>s expected %<allowed>s'- CLASS_DELIM =
','
Instance Method Summary collapse
-
#call(value) ⇒ Object
Check value for instance of expected class.
Instance Method Details
#call(value) ⇒ Object
Check value for instance of expected class
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/devtools/config.rb', line 24 def call(value) klass = value.class format_values = { name: name, got: klass, allowed: allowed_classes.join(CLASS_DELIM) } unless allowed_classes.any?(&klass.method(:equal?)) fail TypeError, format(ERROR_FORMAT, format_values) end value end |