Class: ActionDispatch::Router::Route

Inherits:
Object
  • Object
show all
Defined in:
runtime/action_dispatch/router.rb,
runtime/action_dispatch/router.rbs

Overview

One entry in the route table: a typed class so each per-field type is statically known. verb rather than method, which Ruby's Object already answers.

controller holds the class, not a symbol: the dispatcher calls matched.controller.new, and a symbol would need a second mapping back to the class that drifts from the table.

Positional initialize: keywords do not convert symmetrically between definition and call site, and this is an internal class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, pattern, controller, action, req_format = nil, int_params = +"")) ⇒ Route

the route-forced response format (a route declared get "/rss" => "home#index", :format => "rss"), nil for the common infer-from-path case. Named req_format (not format) so targets whose stdlibs claim format never collide.

int_params — space-joined names of path params constrained to digit-only segments (Roda's Integer matcher, a constraints: digit class), e.g. "id" or "article_id id"; the empty string for the unconstrained common case. A candidate segment that isn't all digits makes the route a non-match, so /articles/12abc falls through to 404 instead of binding id = "12abc".

Parameters:

  • verb (String) —

    the HTTP verb ("GET", "POST", ...)

  • pattern (String) —

    the path pattern, e.g. "/devices/:id"

  • controller (Class) —

    the controller class dispatched to

  • action (Symbol) —

    the action dispatched

  • req_format (Symbol, nil) (defaults to: nil) —

    route-forced response format

  • int_params (String) (defaults to: +"")) —

    space-joined digit-constrained param names



42
# File 'runtime/action_dispatch/router.rb', line 42

def initialize: (String verb, String pattern, Class controller, Symbol action, ?Symbol? req_format, ?String int_params) -> void

Instance Attribute Details

#action ⇒ Symbol (readonly)

Returns:

  • (Symbol)


7
# File 'runtime/action_dispatch/router.rbs', line 7

def action: () -> Symbol

#controller ⇒ Class (readonly)

Returns:

  • (Class)


6
# File 'runtime/action_dispatch/router.rbs', line 6

def controller: () -> Class

#int_params ⇒ String (readonly)

Returns:



9
# File 'runtime/action_dispatch/router.rbs', line 9

def int_params: () -> String

#pattern ⇒ String (readonly)

Returns:



5
# File 'runtime/action_dispatch/router.rbs', line 5

def pattern: () -> String

#pattern_parts ⇒ Array[String] (readonly)

Returns:



10
# File 'runtime/action_dispatch/router.rbs', line 10

def pattern_parts: () -> Array[String]

#req_format ⇒ Symbol? (readonly)

Returns:

  • (Symbol, nil)


8
# File 'runtime/action_dispatch/router.rbs', line 8

def req_format: () -> Symbol?

#verb ⇒ String (readonly)

Returns:



4
# File 'runtime/action_dispatch/router.rbs', line 4

def verb: () -> String