module T::Enum::LegacyMigrationMode

def ==(other)

def ==(other)
  case other
  when String
    if T::Configuration.legacy_t_enum_migration_mode?
      comparison_assertion_failed(:==, other)
      self.serialize == other
    else
      false
    end
  else
    super(other)
  end
end

def ===(other)

def ===(other)
  case other
  when String
    if T::Configuration.legacy_t_enum_migration_mode?
      comparison_assertion_failed(:===, other)
      self.serialize == other
    else
      false
    end
  else
    super(other)
  end
end

def comparison_assertion_failed(method, other)

def comparison_assertion_failed(method, other)
figuration.soft_assert_handler(
m to string comparison not allowed. Compare to the Enum instance directly instead. See go/enum-migration',
ytime: {
ass: self.class.name,
lf: self.inspect,
her: other,
her_class: other.class.name,
thod: method,
ller_location: Kernel.caller_locations(2..2)&.[](0)&.then {"#{_1.path}:#{_1.lineno}"},

def serialize; end

def serialize; end

def to_str

def to_str
  msg = 'Implicit conversion of Enum instances to strings is not allowed. Call #serialize instead.'
  if T::Configuration.legacy_t_enum_migration_mode?
    T::Configuration.soft_assert_handler(
      msg,
      storytime: {
        class: self.class.name,
        caller_location: Kernel.caller_locations(1..1)&.[](0)&.then {"#{_1.path}:#{_1.lineno}"},
      },
    )
    serialize.to_s
  else
    Kernel.raise NoMethodError.new(msg)
  end
end