Class: Ruact::ServerFunctions::QueryContext
- Inherits:
-
Object
- Object
- Ruact::ServerFunctions::QueryContext
- Defined in:
- lib/ruact/server_functions/query_context.rb
Overview
Story 9.4 (D3) — per-request execution context injected into a
Query subclass by the internal query dispatch controller. A
fresh instance is built per request (NFR8) wrapping the DISPATCHING
controller instance; because that controller inherits
Ruact.config.query_parent_controller, every delegated reader resolves
to the host's own machinery — current_user IS the host's method
(Devise / Pundit / hand-rolled), not a gem-side resolver lambda.
Mirrors the SHAPE of the Story-8.3 StandaloneContext (plain accessors,
per-request instance) while sourcing everything from the controller —
the resolver-lambda pattern is superseded by the 2026-06-02 ADR
addendum (Decision 2).
Instance Method Summary collapse
-
#current_user ⇒ Object?
The host's authenticated user.
-
#initialize(controller:) ⇒ QueryContext
constructor
A new instance of QueryContext.
-
#params ⇒ ActionController::Parameters
The request params (query-string parameters on a GET query route).
-
#request ⇒ ActionDispatch::Request
The live request.
-
#session ⇒ ActionDispatch::Request::Session
The host middleware's session.
Constructor Details
#initialize(controller:) ⇒ QueryContext
Returns a new instance of QueryContext.
20 21 22 |
# File 'lib/ruact/server_functions/query_context.rb', line 20 def initialize(controller:) @controller = controller end |
Instance Method Details
#current_user ⇒ Object?
The host's authenticated user. Resolved through the controller's own
current_user — public OR private (hand-rolled apps commonly define
it private). When the host chain defines no current_user at all,
raises a NoMethodError that names the fix instead of a bare
"undefined method" from deep inside a query body.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruact/server_functions/query_context.rb', line 33 def current_user unless @controller.respond_to?(:current_user, true) raise NoMethodError, "ruact: the query dispatch controller (inheriting " \ "#{@controller.class.superclass.name}, via Ruact.config.query_parent_controller) " \ "does not define `current_user`. Define it on the parent controller, or point " \ "`query_parent_controller` at a controller that does." end @controller.send(:current_user) end |
#params ⇒ ActionController::Parameters
Returns the request params (query-string parameters on a GET query route).
47 48 49 |
# File 'lib/ruact/server_functions/query_context.rb', line 47 def params @controller.params end |
#request ⇒ ActionDispatch::Request
Returns the live request.
52 53 54 |
# File 'lib/ruact/server_functions/query_context.rb', line 52 def request @controller.request end |
#session ⇒ ActionDispatch::Request::Session
Returns the host middleware's session.
57 58 59 |
# File 'lib/ruact/server_functions/query_context.rb', line 57 def session @controller.session end |