Class: OasRails::Builders::OasRouteBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/oas_rails/builders/oas_route_builder.rb

Constant Summary collapse

KNOWN_RUNTIME_WRAPPERS =

Gems/frameworks (like Sorbet) may wrap methods at runtime, causing instance_method.source_location to point to the wrapper rather than the original source file. We detect this and fall back to reading the source file directly so that OasRails annotations remain readable.

%w[sorbet-runtime].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rails_route) ⇒ OasRouteBuilder

Returns a new instance of OasRouteBuilder.



14
15
16
# File 'lib/oas_rails/builders/oas_route_builder.rb', line 14

def initialize(rails_route)
  @rails_route = rails_route
end

Class Method Details

.build_from_rails_route(rails_route) ⇒ Object



10
11
12
# File 'lib/oas_rails/builders/oas_route_builder.rb', line 10

def self.build_from_rails_route(rails_route)
  new(rails_route).build
end

Instance Method Details

#buildObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oas_rails/builders/oas_route_builder.rb', line 18

def build
  OasCore::OasRoute.new(
    controller: controller,
    method_name: method,
    verb: verb,
    path: path,
    docstring: docstring,
    source_string: source_string,
    tags: tags
  )
end