Class: Praxis::BootloaderStages::Routing

Inherits:
Stage
  • Object
show all
Defined in:
lib/praxis/bootloader_stages/routing.rb

Defined Under Namespace

Classes: Target

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

#executeObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/praxis/bootloader_stages/routing.rb', line 23

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



35
36
37
38
39
# File 'lib/praxis/bootloader_stages/routing.rb', line 35

def target_factory(controller, action_name)
  action = controller.definition.actions.fetch(action_name)

  Target.new(application, controller, action)
end