Class: Lutaml::Model::Schema::Generator::Ref

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/schema/generator/ref.rb

Overview

This class is used to generate a reference to a schema definition. It is used in the context of generating JSON schemas.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Ref

Returns a new instance of Ref.



10
11
12
13
# File 'lib/lutaml/model/schema/generator/ref.rb', line 10

def initialize(type)
  @type = type
  @name = @type.name.gsub("::", "_")
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/lutaml/model/schema/generator/ref.rb', line 8

def name
  @name
end

Instance Method Details

#to_schemaObject



15
16
17
18
19
# File 'lib/lutaml/model/schema/generator/ref.rb', line 15

def to_schema
  {
    "$ref" => "#/$defs/#{name}",
  }
end