Class: Lutaml::Model::Schema::BaseSchema
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::BaseSchema
- Defined in:
- lib/lutaml/model/schema/base_schema.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #generate_schema_hash ⇒ Object
-
#initialize(klass, schema:, id: nil, title: nil, description: nil) ⇒ BaseSchema
constructor
A new instance of BaseSchema.
Constructor Details
#initialize(klass, schema:, id: nil, title: nil, description: nil) ⇒ BaseSchema
Returns a new instance of BaseSchema.
26 27 28 29 30 31 32 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 26 def initialize(klass, schema:, id: nil, title: nil, description: nil) @schema = schema @klass = klass @id = id @title = title @description = description end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
24 25 26 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 24 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
24 25 26 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 24 def id @id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
23 24 25 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 23 def klass @klass end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
23 24 25 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 23 def schema @schema end |
#title ⇒ Object
Returns the value of attribute title.
24 25 26 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 24 def title @title end |
Class Method Details
.generate(klass, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 10 def generate(klass, = {}) schema = new( klass, schema: [:schema], id: [:id], title: [:title], description: [:description], ).generate_schema_hash format_schema(schema, ) end |
Instance Method Details
#generate_schema_hash ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/lutaml/model/schema/base_schema.rb', line 34 def generate_schema_hash { "$schema" => schema, "$id" => id, "description" => description, "$ref" => "#/$defs/#{klass.name.gsub('::', '_')}", "$defs" => generate_definitions(klass), }.compact end |