Sha256: 8b61d374bae2567c17bd8da571bade66c75f378f0bb4bcc041ef4076205e2765

Contents?: true

Size: 964 Bytes

Versions: 7

Compression:

Stored size: 964 Bytes

Contents

class Rack::App::Endpoint::Executor

  def initialize(endpoint_properties)
    @endpoint_properties = endpoint_properties
  end

  def call(env)
    return catch(:rack_response){ execute(env) }.finish
  end

  protected

  def execute(env)
    request_handler = env[Rack::App::Constants::ENV::REQUEST_HANDLER]
    set_response_body(request_handler.response, get_response_body(request_handler))
    return request_handler.response
  end

  def get_response_body(request_handler)
    catch :response_body do
      evaluated_value = evaluate_value(request_handler)

      evaluated_value
    end
  end

  def set_response_body(response, response_body)
    response.write(String(@endpoint_properties.serializer.serialize(response_body)))
  end

  def evaluate_value(request_handler)
    @endpoint_properties.error_handler.execute_with_error_handling_for(request_handler) do
      request_handler.__send__(@endpoint_properties.endpoint_method_name)
    end
  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-app-5.4.0 lib/rack/app/endpoint/executor.rb
rack-app-5.3.2 lib/rack/app/endpoint/executor.rb
rack-app-5.3.1 lib/rack/app/endpoint/executor.rb
rack-app-5.3.0 lib/rack/app/endpoint/executor.rb
rack-app-5.2.0 lib/rack/app/endpoint/executor.rb
rack-app-5.1.0 lib/rack/app/endpoint/executor.rb
rack-app-5.0.0 lib/rack/app/endpoint/executor.rb