Class: JsxRosetta::PagesRouting::Route
- Inherits:
-
Data
- Object
- Data
- JsxRosetta::PagesRouting::Route
- Defined in:
- lib/jsx_rosetta/pages_routing.rb
Overview
A single route resolved from the pages tree.
‘namespace` is `[]` for top-level routes, otherwise an ordered list of Rails namespace segments (slice-4 B3 nested dirs + B5 route groups). Both shapes flow into the same array — Naming + Emitter wrap routes in nested `namespace :foo do` blocks regardless of which mechanism added the segment.
‘kind` is `:standard` for regular GET routes, `:error_page` for `_error.tsx` / `404.tsx` / `500.tsx` (emitted via `config.exceptions_app` rather than the regular draw block), or `:layout` for `_app.tsx` (emitted as a view-placement directive only, not a route line).
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#rails_path ⇒ Object
readonly
Returns the value of attribute rails_path.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
Instance Method Summary collapse
-
#initialize(rails_path:, controller:, action:, source_path:, namespace: [], kind: :standard) ⇒ Route
constructor
A new instance of Route.
-
#url_params ⇒ Object
Extracts the named URL params from ‘rails_path` in order.
Constructor Details
#initialize(rails_path:, controller:, action:, source_path:, namespace: [], kind: :standard) ⇒ Route
Returns a new instance of Route.
32 33 34 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 32 def initialize(rails_path:, controller:, action:, source_path:, namespace: [], kind: :standard) super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def controller @controller end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def kind @kind end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def namespace @namespace end |
#rails_path ⇒ Object (readonly)
Returns the value of attribute rails_path
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def rails_path @rails_path end |
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path
31 32 33 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 31 def source_path @source_path end |
Instance Method Details
#url_params ⇒ Object
Extracts the named URL params from ‘rails_path` in order. Catches `:foo`, `*rest`, and `(/*extra)`-style optional catch-alls.
38 39 40 41 42 |
# File 'lib/jsx_rosetta/pages_routing.rb', line 38 def url_params return [] if rails_path.nil? rails_path.scan(/[:*]([a-z_][a-z0-9_]*)/i).flatten end |