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.



8
9
10
# File 'lib/openapi3_parser/node_factory/optional_reference.rb', line 8

def initialize(factory)
  @factory = factory
end

Instance Method Details

#call(context) ⇒ Object



12
13
14
15
16
# File 'lib/openapi3_parser/node_factory/optional_reference.rb', line 12

def call(context)
  reference = context.input.is_a?(Hash) && context.input["$ref"]
  return NodeFactories::Reference.new(context, self) if reference
  factory.new(context)
end