Module: Racket::Utils::Routing
- Defined in:
- lib/racket/utils/routing.rb
Overview
Utility functions for routing.
Defined Under Namespace
Classes: ActionCache, RouterParams
Class Method Summary collapse
-
.extract_target(response) ⇒ Array
Extracts the target class, target params and target action from a list of valid routes.
-
.render_controller(env, target_info) ⇒ Array
Renders a controller.
Class Method Details
.extract_target(response) ⇒ Array
Extracts the target class, target params and target action from a list of valid routes.
76 77 78 79 80 81 |
# File 'lib/racket/utils/routing.rb', line 76 def self.extract_target(response) target_klass = response.route.dest params = response.param_values.first.reject(&:empty?) action = params.empty? ? target_klass.settings.fetch(:default_action) : params.shift.to_sym [target_klass, params, action] end |
.render_controller(env, target_info) ⇒ Array
Renders a controller. This is the default action whenever a matching route for a request is found.
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/racket/utils/routing.rb', line 95 def self.render_controller(env, target_info) controller_class, params, action = target_info # Rewrite PATH_INFO to reflect that we split out the parameters update_path_info(env, params.length) # Initialize and render target call_controller( controller_class, Current.init(RouterParams.new(action, params, env)) ) end |