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



29
30
31
32
33
34
35
36
# File 'lib/praxis/bootloader_stages/routing.rb', line 29

def execute
  application.controllers.each do |controller|
    controller.definition.actions.each do |action_name, action|
      target = target_factory(controller, action_name)
      application.router.add_route target, action.route
    end
  end
end

#target_factory(controller, action_name) ⇒ Object



38
39
40
41
42
# File 'lib/praxis/bootloader_stages/routing.rb', line 38

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

  Target.new(application, controller, action)
end