Class: Openapi3Parser::NodeFactory::OptionalReference

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/node_factory/optional_reference.rb

Instance Method Summary collapse

Constructor Details

#initialize(factory) ⇒ OptionalReference

Returns a new instance of OptionalReference.


6
7
8
# File 'lib/openapi3_parser/node_factory/optional_reference.rb', line 6

def initialize(factory)
  @factory = factory
end

Instance Method Details

#call(context) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/openapi3_parser/node_factory/optional_reference.rb', line 14

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

#object_typeObject


10
11
12
# File 'lib/openapi3_parser/node_factory/optional_reference.rb', line 10

def object_type
  "#{self.class}[#{factory.object_type}]}"
end