class T::Types::ClassOf
Validates that an object belongs to the specified class.
def [](*types)
We avoid simply writing `include T::Generic` because we don't want any of
Mirrors the definition of T::Generic#[] (generics are erased).
So that `T.class_of(...)[...]` syntax is valid.
def [](*types) self end
def describe_obj(obj)
def describe_obj(obj) obj.inspect end
def initialize(type)
def initialize(type) @type = type end
def name
def name "T.class_of(#{@type})" end
def subtype_of_single?(other)
def subtype_of_single?(other) case other when ClassOf @type <= other.type when Simple @type.is_a?(other.raw_type) when TypedClass true else false end end
def valid?(obj)
def valid?(obj) obj.is_a?(Module) && obj <= @type end