Method: T::Enum.serialize

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

.serialize(instance) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sorbet/eraser/t/enum.rb', line 58

def self.serialize(instance)
  return nil if instance.nil?

  if self == T::Enum
    raise "Cannot call T::Enum.serialize directly. You must call on a specific child class."
  end
  if instance.class != self
    raise "Cannot call #serialize on a value that is not an instance of #{self}."
  end
  instance.serialize
end