Class: R2OAS::Schema::V3::Components::SchemaObject

Inherits:
Dynamic::Schema::V3::HookableBaseObject show all
Defined in:
lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb

Instance Attribute Summary

Attributes inherited from Dynamic::Schema::V3::HookableBaseObject

#doc

Instance Method Summary collapse

Methods inherited from Dynamic::Schema::V3::HookableBaseObject

execute_hook, has_hook?, hook, hook=, hooks, inherited, off, on, #use_superclass_hook

Methods inherited from BaseObject

#components_object_class, #components_request_body_object_class, #components_schema_object_class, #external_document_object_class, #info_object_class, #path_item_object_class, #paths_object_class

Constructor Details

#initialize(route_data, path, opts = {}) ⇒ SchemaObject

Returns a new instance of SchemaObject.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb', line 10

def initialize(route_data, path, opts = {})
  super(opts)
  @path_comp    = Routing::PathComponent.new(path)
  @path         = @path_comp.symbol_to_brace
  @route_data   = route_data
  @verb         = route_data[:verb]
  @tag_name     = route_data[:tag_name]
  @schema_name  = route_data[:schema_name]
  # MEMO:
  # Allow primitive types that cannot be passed by reference to be passed by reference
  # This is Compromise
  @ref          = { schema_name: @schema_name, tag_name: @tag_name, verb: @verb }
end

Instance Method Details

#components_schema_name(_doc, _path_component, _tag_name, _verb, _http_status, schema_name) ⇒ Object

MEMO: please override in inherited class.



33
34
35
# File 'lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb', line 33

def components_schema_name(_doc, _path_component, _tag_name, _verb, _http_status, schema_name)
  schema_name
end

#to_docObject



24
25
26
27
28
29
# File 'lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb', line 24

def to_doc
  execute_before_create(@schema_name)
  create_doc
  execute_after_create(@schema_name)
  doc
end