Class: Otto::RouteHandlers::InstanceMethodHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Otto::RouteHandlers::InstanceMethodHandler
- Defined in:
- lib/otto/route_handlers/instance_method.rb
Overview
Handler for instance methods (existing Otto pattern) Route syntax: Controller#action
Controller instances receive full Rack request/response access: - initialize(request, response) with Rack::Request and Rack::Response - Direct access to sessions, cookies, headers, and the raw env
Use this handler for endpoints requiring request-level control (logout, session management, cookie manipulation, custom header handling).
Instance Attribute Summary
Attributes inherited from BaseHandler
#otto_instance, #route_definition
Instance Method Summary collapse
-
#invoke_target(req, res) ⇒ Array
protected
Invoke the instance method on the target class.
Methods inherited from BaseHandler
#call, #finalize_response, #handle_execution_error, #handle_local_error, #handle_response, #handler_name, #initialize, #setup_request_response, #target_class
Constructor Details
This class inherits a constructor from Otto::RouteHandlers::BaseHandler
Instance Method Details
#invoke_target(req, res) ⇒ Array (protected)
Invoke the instance method on the target class
25 26 27 28 29 |
# File 'lib/otto/route_handlers/instance_method.rb', line 25 def invoke_target(req, res) instance = target_class.new(req, res) result = instance.send(route_definition.method_name) [result, { instance: instance, request: req }] end |