Sha256: 4c5eb425184c828c197bc4e33d155b05455ed2911dd420a3d140ba8b9e3d6ab6

Contents?: true

Size: 516 Bytes

Versions: 2

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

require "openapi3_parser/node_factory/reference"

module Openapi3Parser
  module NodeFactory
    class OptionalReference
      def initialize(factory)
        @factory = factory
      end

      def call(context)
        reference = context.input.is_a?(Hash) && context.input["$ref"]

        if reference
          NodeFactory::Reference.new(context, self)
        else
          factory.new(context)
        end
      end

      private

      attr_reader :factory
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openapi3_parser-0.5.1 lib/openapi3_parser/node_factory/optional_reference.rb
openapi3_parser-0.5.0 lib/openapi3_parser/node_factory/optional_reference.rb