Class: OasRails::Extractors::RouteExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/oas_rails/extractors/route_extractor.rb

Constant Summary collapse

RAILS_DEFAULT_CONTROLLERS =
%w[
  rails
  action_mailbox
  action_cable
  active_storage
  turbo/native
].freeze

Class Method Summary collapse

Class Method Details

.clean_route(route) ⇒ Object



34
35
36
# File 'lib/oas_rails/extractors/route_extractor.rb', line 34

def clean_route(route)
  route.gsub('(.:format)', '').gsub(/:\w+/) { |match| "{#{match[1..]}}" }
end

.clear_cacheObject

Clear Class Instance Variable @host_routes

This method clear the class instance variable @host_routes to force a extraction of the routes again.



26
27
28
# File 'lib/oas_rails/extractors/route_extractor.rb', line 26

def clear_cache
  @host_routes = nil
end

.host_pathsObject



30
31
32
# File 'lib/oas_rails/extractors/route_extractor.rb', line 30

def host_paths
  @host_paths ||= host_routes.map(&:path).uniq.sort
end

.host_routesObject



18
19
20
# File 'lib/oas_rails/extractors/route_extractor.rb', line 18

def host_routes
  @host_routes ||= extract_host_routes
end

.host_routes_by_path(path) ⇒ Object



13
14
15
16
# File 'lib/oas_rails/extractors/route_extractor.rb', line 13

def host_routes_by_path(path)
  @host_routes ||= extract_host_routes
  @host_routes.select { |r| r.path == path }
end