def cast(value)
      if value.is_a?(MySQLBinUUID::Type::Data)
        # It could be a Data object, in which case we should add dashes to the
        # string value from there.
        add_dashes(value.to_s)
      elsif value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
        # We cannot unpack something that looks like a UUID, with or without
        # dashes. Not entirely sure why ActiveRecord does a weird combination of
        # cast and serialize before anything needs to be saved..
        undashed_uuid = value.unpack1('H*')
        add_dashes(undashed_uuid.to_s)
      else
        super
      end
    end
def cast(value)
      if value.is_a?(MySQLBinUUID::Type::Data)
        # It could be a Data object, in which case we should add dashes to the
        # string value from there.
        add_dashes(value.to_s)
      elsif value.is_a?(String) && value.encoding == Encoding::ASCII_8BIT && strip_dashes(value).length != 32
        # We cannot unpack something that looks like a UUID, with or without
        # dashes. Not entirely sure why ActiveRecord does a weird combination of
        # cast and serialize before anything needs to be saved..
        undashed_uuid = value.unpack1('H*')
        add_dashes(undashed_uuid.to_s)
      else
        super
      end
    end
Invoked when a value that is returned from the database needs to be
 displayed into something readable again.