Class: Praxis::BootloaderStages::Routing
- Defined in:
- lib/praxis/bootloader_stages/routing.rb
Instance Attribute Summary
Attributes inherited from Stage
#after_callbacks, #before_callbacks, #context, #name, #stages
Instance Method Summary collapse
Methods inherited from Stage
#after, #application, #before, #callback_args, #execute_callbacks, #initialize, #run, #setup!, #setup_deferred_callbacks!
Constructor Details
This class inherits a constructor from Praxis::Stage
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/praxis/bootloader_stages/routing.rb', line 8 def execute application.controllers.each do |controller| controller.definition.actions.each do |action_name, action| action.routes.each do |route| target = target_factory(controller, action_name) application.router.add_route target, route end end end end |
#target_factory(controller, action_name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/praxis/bootloader_stages/routing.rb', line 20 def target_factory(controller, action_name) action = controller.definition.actions.fetch(action_name) Proc.new do |request| request.action = action dispatcher = Dispatcher.current( application: application) dispatcher.dispatch(controller, action, request) end end |