module ActiveJob::Serializers
def add_serializers(*new_serializers)
def add_serializers(*new_serializers) self._additional_serializers += new_serializers.flatten end
def deserialize(argument)
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)
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
def serializers self._additional_serializers end