module ActiveJob::Serializers

def add_serializers(*new_serializers)

Adds new serializers to a list of known serializers.
def add_serializers(*new_serializers)
  self._additional_serializers += new_serializers.flatten
end

def deserialize(argument)

If no serializer found will raise ArgumentError.
Will look up through all known serializers.
Returns deserialized object.
def deserialize(argument)
  serializer_name = argument[Arguments::OBJECT_SERIALIZER_KEY]
  raise ArgumentError, "Serializer name is not present in the argument: #{argument.inspect}" unless serializer_name
  serializer = serializer_name.safe_constantize
  raise ArgumentError, "Serializer #{serializer_name} is not known" unless serializer
  serializer.deserialize(argument)
end

def serialize(argument)

Raises ActiveJob::SerializationError if it can't find a proper serializer.
Will look up through all known serializers.
Returns serialized representative of the passed object.
def serialize(argument)
  serializer = serializers.detect { |s| s.serialize?(argument) }
  raise SerializationError.new("Unsupported argument type: #{argument.class.name}") unless serializer
  serializer.serialize(argument)
end

def serializers

Returns list of known serializers.
def serializers
  self._additional_serializers
end