Class: Otto::RouteHandlers::ClassMethodHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Otto::RouteHandlers::ClassMethodHandler
- Defined in:
- lib/otto/route_handlers/class_method.rb
Overview
Handler for class methods (existing Otto pattern) Route syntax: Controller.action
Class methods receive full Rack request/response access: - Method signature: def self.action(request, 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 class 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 class method on the target class
25 26 27 28 |
# File 'lib/otto/route_handlers/class_method.rb', line 25 def invoke_target(req, res) result = target_class.send(route_definition.method_name, req, res) [result, { class: target_class, request: req }] end |