Class: Praxis::RequestStages::Action

Inherits:
RequestStage show all
Defined in:
lib/praxis/request_stages/action.rb

Instance Attribute Summary

Attributes inherited from Stage

#after_callbacks, #before_callbacks, #context, #name, #stages

Instance Method Summary collapse

Methods inherited from RequestStage

#execute_controller_callbacks, #execute_with_around, #path, #run

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



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/praxis/request_stages/action.rb', line 6

def execute
  response = controller.send(action.name, **request.params_hash)
  case response
  when String
    controller.response.body = response
  when Praxis::Response
    controller.response = response
  else
    raise "Action #{action.name} in #{controller.class} returned #{response.inspect}. Only Response objects or Strings allowed."
  end  
  controller.response.request = request
  nil # Action cannot return its OK request, as it would indicate the end of the stage chain
end