Sha256: ae72f0f26e1cf1d8d12d46448192e79a4665d0e7381d2b61a6373931d94d39df
Contents?: true
Size: 629 Bytes
Versions: 68
Compression:
Stored size: 629 Bytes
Contents
# frozen_string_literal: true # typed: true module T::Types # Validates that an object belongs to the specified class. class ClassOf < Base attr_reader :type def initialize(type) @type = type end # overrides Base def name "T.class_of(#{@type})" end # overrides Base def valid?(obj) obj.is_a?(Module) && obj <= @type end # overrides Base def subtype_of_single?(other) case other when ClassOf @type <= other.type else false end end # overrides Base def describe_obj(obj) obj.inspect end end end
Version data entries
68 entries across 68 versions & 1 rubygems