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'.freeze
- CLASS_DELIM =
','.freeze
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
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/devtools/config.rb', line 23 def call(value) klass = value.class unless allowed_classes.any?(&klass.method(:equal?)) fail TypeError, ERROR_FORMAT % { name: name, got: klass, allowed: allowed_classes.join(CLASS_DELIM) } end value end |