Sha256: c25f3ac11a7626d097b979b8e410cfde5db7e0f4ef1d46374f12389181cb8bde
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true class OAPI::OpenAPI::V30::Serializers::Serializer FUNCTIONS = { # order matters OAPI::Ref => "serialize_ref", OAPI::Schema => "serialize_schema", OAPI::OpenAPI::V30::Definition => "serialize_definition", OAPI::Types::Map => "serialize_map", OAPI::Types::Array => "serialize_array", OAPI::Types::Object => "serialize_object" }.freeze class << self def serialize(node) = new.send(serializer(node), node) def serializer(node) = FUNCTIONS.find { |k, _| node.is_a?(k) }&.at(1) def supported?(node) = !serializer(node).nil? def serialize_if_supported(node) = supported?(node) ? serialize(node) : node end private def serialize_if_supported(*) = self.class.serialize_if_supported(*) def serialize(*) = self.class.serialize(*) def serialize_ref(ref) = raise NotImplementedError def serialize_schema(schema) = raise NotImplementedError def serialize_definition(definition) = serialize_object(definition) def serialize_map(map) = raise NotImplementedError def serialize_array(array) = raise NotImplementedError def serialize_object(object) = raise NotImplementedError end
Version data entries
4 entries across 4 versions & 1 rubygems