Class: Inertia::ProtocolBuilder
- Inherits:
-
Object
- Object
- Inertia::ProtocolBuilder
- Defined in:
- lib/inertia/protocol_builder.rb,
lib/inertia/_codex_protocol_builder.rb
Overview
Builds the Inertia page object for a rendered component.
ProtocolBuilder resolves the server-side props hash into the shape expected
by the Inertia protocol. It applies partial reload filtering, evaluates lazy
values, walks nested hashes and arrays, and collects protocol metadata such
as deferredProps and onceProps.
Nested prop paths are tracked with dot notation, e.g. auth.user.name, so
request headers can target either a top-level prop or a nested value.
Constant Summary collapse
- OMITTED =
Object.new.freeze
Instance Method Summary collapse
-
#call ⇒ Hash
Builds the page object hash.
-
#initialize(component, props, context:) ⇒ ProtocolBuilder
constructor
Creates a new protocol builder.
Constructor Details
#initialize(component, props, context:) ⇒ ProtocolBuilder
Creates a new protocol builder.
26 27 28 29 30 31 |
# File 'lib/inertia/protocol_builder.rb', line 26 def initialize(component, props, context:) @props = props @context = context @response = { component:, url: context.url, version: Frontend.version } end |
Instance Method Details
#call ⇒ Hash
Builds the page object hash.
36 37 38 39 40 41 42 |
# File 'lib/inertia/protocol_builder.rb', line 36 def call @response[:props] = resolve_props @response[:deferredProps] = @deferred_props_metadata if @deferred_props_metadata @response[:onceProps] = @once_props_metadata if @once_props_metadata @response end |