Class: Praxis::RequestStages::Response

Inherits:
RequestStage show all
Defined in:
lib/praxis/request_stages/response.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
19
20
21
# File 'lib/praxis/request_stages/response.rb', line 6

def execute
  response = controller.response

  unless action.responses.include?(response.response_name)
    raise Exceptions::InvalidResponse.new(
      "Response #{response.name.inspect} is not allowed for #{action.name.inspect}"
    )
  end

  response.handle

  praxis_config = Application.instance.config.praxis
  unless praxis_config && praxis_config.validate_responses == false
    response.validate(action)
  end
end