Method: T::Enum.has_serialized?

Defined in:
lib/sorbet/eraser/t/enum.rb

.has_serialized?(serialized_val) ⇒ Boolean

Note: It would have been nice to make this method final before people started overriding it.

Returns:

  • (Boolean)

    Does the given serialized value correspond with any of this enum’s values.



50
51
52
53
54
55
56
# File 'lib/sorbet/eraser/t/enum.rb', line 50

def self.has_serialized?(serialized_val)
  if @mapping.nil?
    raise "Attempting to access serialization map of #{self.class} before it has been initialized." \
      " Enums are not initialized until the 'enums do' block they are defined in has finished running."
  end
  @mapping.include?(serialized_val)
end