Module: Ruact::ServerFunctions::BucketTwoPayload
- Defined in:
- lib/ruact/server_functions/bucket_two_payload.rb
Overview
Story 9.2 — pure serializer for the Bucket-2 (imperative ‘await fn()`) response body. Takes the host action’s exposed instance variables (Rails ‘view_assigns`, resolved by the caller) and produces a JSON-ready Ruby Hash, keyed by ivar name, applying the SAME prop-exposure policy as the Flight serializer (Flight::Serializer#serialize_unknown):
- {Ruact::Serializable} values expose ONLY their `ruact_props` (secrets
never leak), recursing into nested Serializables / collections.
- Under `strict_serialization`, a non-Serializable domain object raises
{Ruact::SerializationError} (no accidental full-record dump).
- Otherwise a vetted `as_json` fallback applies (guards against
`as_json` returning self / raising).
Unlike the Flight serializer this produces PLAIN JSON-ready values (Hash / Array / scalar) — ‘render json:` does the final encoding, so JSON primitives (incl. Time/Date) pass through untouched rather than being Flight-encoded.
Pure — no Rails / request / ‘Ruact.config` reads. The caller resolves the exposed-ivar set and the `strict` flag (mirroring the ErrorPayload caller/builder split, NFR26 / AC8).
Class Method Summary collapse
-
.build(assigns, strict:) ⇒ Hash{String=>Object}
JSON-ready hash keyed by ivar name.
-
.serialize_value(value, strict:) ⇒ Object
Story 9.4 (D6) — the per-value branch of the policy, extracted so the query dispatch controller serializes a method’s single RETURN VALUE (Array / Hash / scalar / Serializable / nil) through the exact rules BucketTwoPayload.build applies to each exposed ivar.
Class Method Details
.build(assigns, strict:) ⇒ Hash{String=>Object}
Returns JSON-ready hash keyed by ivar name.
43 44 45 |
# File 'lib/ruact/server_functions/bucket_two_payload.rb', line 43 def build(assigns, strict:) assigns.to_h { |name, value| [name.to_s, serialize(value, strict)] } end |
.serialize_value(value, strict:) ⇒ Object
Story 9.4 (D6) — the per-value branch of the policy, extracted so the query dispatch controller serializes a method’s single RETURN VALUE (Array / Hash / scalar / Serializable / nil) through the exact rules build applies to each exposed ivar. One policy, two callers.
56 57 58 |
# File 'lib/ruact/server_functions/bucket_two_payload.rb', line 56 def serialize_value(value, strict:) serialize(value, strict) end |