Sha256: e428223f960f8457b9b178d5a32f2ccd30569814857e9d8be249dca5197141cc
Contents?: true
Size: 708 Bytes
Versions: 249
Compression:
Stored size: 708 Bytes
Contents
# frozen_string_literal: true # typed: true module T::Types # validates that the provided value is within a given set/enum class Enum < Base extend T::Sig attr_reader :values def initialize(values) @values = values end # overrides Base def valid?(obj) @values.member?(obj) end # overrides Base private def subtype_of_single?(other) case other when Enum (other.values - @values).empty? else false end end # overrides Base def name @name ||= "T.deprecated_enum([#{@values.map(&:inspect).join(', ')}])" end # overrides Base def describe_obj(obj) obj.inspect end end end
Version data entries
249 entries across 243 versions & 3 rubygems