Sha256: a2fa2ac95d19bf1af1fc7047d5bfc7911d0d828187c46a4e42c30e2e91ae7c80

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 Bytes

Contents

module Praxis
  module RequestStages

    class Action < RequestStage 
      
      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
            
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
praxis-0.10.1 lib/praxis/request_stages/action.rb
praxis-0.10.0 lib/praxis/request_stages/action.rb