Class: Woods::Extractors::RouteExtractor

Inherits:
Object
  • Object
show all
Includes:
SharedUtilityMethods
Defined in:
lib/woods/extractors/route_extractor.rb

Overview

RouteExtractor handles Rails route extraction via runtime introspection.

Unlike file-based extractors, RouteExtractor reads the live routing table from ‘Rails.application.routes.routes`. Each route becomes an ExtractedUnit with metadata about HTTP method, path, controller, and action.

Examples:

extractor = RouteExtractor.new
units = extractor.extract_all
 = units.find { |u| u.identifier == "POST /login" }

Instance Method Summary collapse

Methods included from SharedUtilityMethods

#app_source?, #condition_label, #count_loc, #detect_entry_points, #extract_action_filter_actions, #extract_callback_conditions, #extract_class_methods, #extract_class_name, #extract_custom_errors, #extract_initialize_params, #extract_namespace, #extract_parent_class, #extract_public_methods, #resolve_source_location, #skip_file?

Constructor Details

#initializeRouteExtractor

Returns a new instance of RouteExtractor.



23
24
25
# File 'lib/woods/extractors/route_extractor.rb', line 23

def initialize
  # No directories to scan — this is runtime introspection
end

Instance Method Details

#extract_allArray<ExtractedUnit>

Extract all routes from the Rails routing table

Returns:



30
31
32
33
34
35
# File 'lib/woods/extractors/route_extractor.rb', line 30

def extract_all
  return [] unless rails_routes_available?

  routes = Rails.application.routes.routes
  routes.filter_map { |route| extract_route(route) }
end