@@ -284,12 +284,64 @@ module ActionDispatch {
284
284
* resources :photos
285
285
* ```
286
286
*/
287
- abstract class Route extends TRoute {
287
+ class Route extends TRoute instanceof RouteImpl {
288
288
/**
289
289
* Gets the name of a primary CodeQL class to which this route belongs.
290
290
*/
291
291
string getAPrimaryQlClass ( ) { result = "Route" }
292
292
293
+ /** Gets a string representation of this route. */
294
+ string toString ( ) { result = super .toString ( ) }
295
+
296
+ /**
297
+ * Gets the location of the method call that defines this route.
298
+ */
299
+ Location getLocation ( ) { result = super .getLocation ( ) }
300
+
301
+ /**
302
+ * Gets the full controller targeted by this route.
303
+ */
304
+ string getController ( ) { result = super .getController ( ) }
305
+
306
+ /**
307
+ * Gets the action targeted by this route.
308
+ */
309
+ string getAction ( ) { result = super .getAction ( ) }
310
+
311
+ /**
312
+ * Gets the HTTP method of this route.
313
+ * The result is one of [get, post, put, patch, delete].
314
+ */
315
+ string getHttpMethod ( ) { result = super .getHttpMethod ( ) }
316
+
317
+ /**
318
+ * Gets the full path of the route.
319
+ */
320
+ string getPath ( ) { result = super .getPath ( ) }
321
+
322
+ /**
323
+ * Get a URL capture. This is a wildcard URL segment whose value is placed in `params`.
324
+ * For example, in
325
+ * ```ruby
326
+ * get "/foo/:bar/baz", to: "users#index"
327
+ * ```
328
+ * the capture is `:bar`.
329
+ */
330
+ string getACapture ( ) { result = super .getACapture ( ) }
331
+ }
332
+
333
+ /**
334
+ * The implementation of `Route`.
335
+ * This class is abstract and is thus kept private so we don't expose it to
336
+ * users.
337
+ * Extend this class to add new instances of routes.
338
+ */
339
+ abstract private class RouteImpl extends TRoute {
340
+ /**
341
+ * Gets the name of a primary CodeQL class to which this route belongs.
342
+ */
343
+ string getAPrimaryQlClass ( ) { result = "RouteImpl" }
344
+
293
345
MethodCall method ;
294
346
295
347
/** Gets a string representation of this route. */
@@ -319,7 +371,7 @@ module ActionDispatch {
319
371
* Gets the HTTP method of this route.
320
372
* The result is one of [get, post, put, patch, delete].
321
373
*/
322
- abstract string getHTTPMethod ( ) ;
374
+ abstract string getHttpMethod ( ) ;
323
375
324
376
/**
325
377
* Gets the last controller component.
@@ -420,7 +472,7 @@ module ActionDispatch {
420
472
* put "/photos/:id", to: "photos#update"
421
473
* ```
422
474
*/
423
- private class ExplicitRoute extends Route , TExplicitRoute {
475
+ private class ExplicitRoute extends RouteImpl , TExplicitRoute {
424
476
RouteBlock parentBlock ;
425
477
426
478
ExplicitRoute ( ) { this = TExplicitRoute ( parentBlock , method ) }
@@ -485,7 +537,7 @@ module ActionDispatch {
485
537
)
486
538
}
487
539
488
- override string getHTTPMethod ( ) { result = method .getMethodName ( ) .toString ( ) }
540
+ override string getHttpMethod ( ) { result = method .getMethodName ( ) .toString ( ) }
489
541
}
490
542
491
543
/**
@@ -519,7 +571,7 @@ module ActionDispatch {
519
571
* get "/photos/:photo_id/foo", to: "photos#foo"
520
572
* ```
521
573
*/
522
- private class ResourcesRoute extends Route , TResourcesRoute {
574
+ private class ResourcesRoute extends RouteImpl , TResourcesRoute {
523
575
RouteBlock parent ;
524
576
string resource ;
525
577
string action ;
@@ -544,7 +596,7 @@ module ActionDispatch {
544
596
545
597
override string getAction ( ) { result = action }
546
598
547
- override string getHTTPMethod ( ) { result = httpMethod }
599
+ override string getHttpMethod ( ) { result = httpMethod }
548
600
}
549
601
550
602
/**
@@ -556,7 +608,7 @@ module ActionDispatch {
556
608
* resource :account
557
609
* ```
558
610
*/
559
- private class SingularResourceRoute extends Route , TResourceRoute {
611
+ private class SingularResourceRoute extends RouteImpl , TResourceRoute {
560
612
RouteBlock parent ;
561
613
string resource ;
562
614
string action ;
@@ -581,7 +633,7 @@ module ActionDispatch {
581
633
582
634
override string getAction ( ) { result = action }
583
635
584
- override string getHTTPMethod ( ) { result = httpMethod }
636
+ override string getHttpMethod ( ) { result = httpMethod }
585
637
}
586
638
587
639
/**
@@ -597,7 +649,7 @@ module ActionDispatch {
597
649
* match 'photos/:id', controller: 'photos', action: 'show', via: :get
598
650
* ```
599
651
*/
600
- private class MatchRoute extends Route , TMatchRoute {
652
+ private class MatchRoute extends RouteImpl , TMatchRoute {
601
653
private RouteBlock parent ;
602
654
603
655
MatchRoute ( ) { this = TMatchRoute ( parent , method ) }
@@ -625,7 +677,7 @@ module ActionDispatch {
625
677
.getStringOrSymbol ( ) )
626
678
}
627
679
628
- override string getHTTPMethod ( ) {
680
+ override string getHttpMethod ( ) {
629
681
exists ( string via |
630
682
method .getKeywordArgument ( "via" ) .getConstantValue ( ) .isStringOrSymbol ( via )
631
683
|
0 commit comments