Class: JsxRosetta::PagesRouting::Route

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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

#actionObject (readonly)

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller

Returns:

  • (Object)

    the current value of controller



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def controller
  @controller
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def kind
  @kind
end

#namespaceObject (readonly)

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def namespace
  @namespace
end

#rails_pathObject (readonly)

Returns the value of attribute rails_path

Returns:

  • (Object)

    the current value of rails_path



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def rails_path
  @rails_path
end

#source_pathObject (readonly)

Returns the value of attribute source_path

Returns:

  • (Object)

    the current value of source_path



31
32
33
# File 'lib/jsx_rosetta/pages_routing.rb', line 31

def source_path
  @source_path
end

Instance Method Details

#url_paramsObject

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