Class: Praxis::BootloaderStages::Routing::Target

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application, controller, action) ⇒ Target

Returns a new instance of Target.



9
10
11
12
13
# File 'lib/praxis/bootloader_stages/routing.rb', line 9

def initialize(application, controller, action)
  @application = application
  @controller = controller
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/praxis/bootloader_stages/routing.rb', line 7

def action
  @action
end

Instance Method Details

#call(request) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/praxis/bootloader_stages/routing.rb', line 15

def call(request)
  dispatcher = Dispatcher.current(application: @application)
  # Switch to the sister get action if configured that way (and mark the request as forwarded)
  action = \
    if @action.sister_get_action
      request.forwarded_from_action = @action
      @action.sister_get_action
    else
      @action
    end
  dispatcher.dispatch(@controller, action, request)
end