class Devtools::Config::TypeCheck

Simple named type check representation

Constants

CLASS_DELIM
ERROR_FORMAT

Public Instance Methods

call(value) click to toggle source

Check value for instance of expected class

@param [Object] value

@return [Object]

# 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