Class: Openapi3Parser::Source::ResolvedReference

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/openapi3_parser/source/resolved_reference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_location:, object_type:, reference_registry:) ⇒ ResolvedReference

Returns a new instance of ResolvedReference.



15
16
17
18
19
20
21
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 15

def initialize(source_location:,
               object_type:,
               reference_registry:)
  @source_location = source_location
  @object_type = object_type
  @reference_registry = reference_registry
end

Instance Attribute Details

#object_typeObject (readonly)

Returns the value of attribute object_type.



13
14
15
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 13

def object_type
  @object_type
end

#source_locationObject (readonly)

Returns the value of attribute source_location.



13
14
15
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 13

def source_location
  @source_location
end

Instance Method Details

#errorsObject



27
28
29
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 27

def errors
  @errors ||= Array(build_errors)
end

#factoryObject



31
32
33
34
35
36
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 31

def factory
  @factory ||= reference_registry.factory(object_type, source_location).tap do |factory|
    message = "Unregistered node factory at #{source_location}"
    raise Openapi3Parser::Error, message unless factory
  end
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/openapi3_parser/source/resolved_reference.rb', line 23

def valid?
  errors.empty?
end