Class: Axn::Internal::Reflection::Schema::ShapePropertyPlan
- Inherits:
-
Data
- Object
- Data
- Axn::Internal::Reflection::Schema::ShapePropertyPlan
- Defined in:
- lib/axn/internal/reflection/schema.rb
Overview
Whether a config's shape: members become object PROPERTIES, at which node, and which property names
its declared TYPE contributes alongside them.
Single source for the two layers that must agree exactly: apply_structured_schema! above, which
emits, and Core::Contract's property-claim collector, which rejects a declaration whose emitted
property names would collapse onto one. The guard has to claim precisely what is emitted — a claim for
a property the schema omits rejects a declaration the author is entitled to write, and a missing claim
lets two names collapse silently. A guard that MIRRORED these rules did both at once, so they live
here, where the emission decision already lived, and are read rather than restated.
in_items? distinguishes the two nodes a shape's members can land at: an ARRAY's element properties
are their own namespace (a non-object parent's subfields are not emitted there, so nothing else can
name a property alongside them), while everything else lands in the field's own properties.
emitted false means the shape contributes no properties at all, for one of four reasons:
- the config is wholly gated on output, so `build_property` leaves it untyped before reaching here;
- the config is a `model:` route on INPUT, where the client sends `<field>_id` and the record's own
structure is never emitted — `build_input` (and the nested analog) emit the id property INSTEAD of
calling `build_property` at all, at top level and at any subfield depth alike;
- a SCALAR `of:` (`of: String` + `field :length`) reads members off the element, which stays a
string — so the members are validated but never become properties;
- on OUTPUT, the value is not provably member-keyed (a custom `as_json`/`to_h` that
`serialize_value` would follow instead), so the property is left untyped rather than promising an
object shape the serializer will not produce.
type_schema is what the declared TYPE contributes, as the emitter's own Hash: for an array, exactly
what items_schema_for seeded from the of: element type; for a non-array, a Data field's own
members. Carried whole rather than reduced to one property list, because the emitter does not put all
of it at one node — a multi-class of: becomes one anyOf BRANCH per element type, each with its own
properties. base_properties is the part that lands at the node itself, which is all the emitter
merges the shape's members into; a consumer that must account for EVERY name (the projection size cap)
walks the whole schema instead. Reducing this to base_properties alone is what let a contract naming
26,000 properties across 26 branches charge zero.
shape is the shape the plan was DERIVED from — the effective one (see effective_validations), which on
output is not always the declared one. Carried so that "which members does this emit" has a single
answer: apply_structured_schema! emits these members, and a rule charged against the plan walks the
same list rather than re-reading the config it came from. A plan whose emitted is false still carries
it (nothing about that decision changes which shape was consulted), so every consumer gates on emitted.
Instance Attribute Summary collapse
-
#emitted ⇒ Object
readonly
Returns the value of attribute emitted.
-
#in_items ⇒ Object
readonly
Returns the value of attribute in_items.
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
-
#type_schema ⇒ Object
readonly
Returns the value of attribute type_schema.
Instance Method Summary collapse
Instance Attribute Details
#emitted ⇒ Object (readonly)
Returns the value of attribute emitted
1394 1395 1396 |
# File 'lib/axn/internal/reflection/schema.rb', line 1394 def emitted @emitted end |
#in_items ⇒ Object (readonly)
Returns the value of attribute in_items
1394 1395 1396 |
# File 'lib/axn/internal/reflection/schema.rb', line 1394 def in_items @in_items end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape
1394 1395 1396 |
# File 'lib/axn/internal/reflection/schema.rb', line 1394 def shape @shape end |
#type_schema ⇒ Object (readonly)
Returns the value of attribute type_schema
1394 1395 1396 |
# File 'lib/axn/internal/reflection/schema.rb', line 1394 def type_schema @type_schema end |
Instance Method Details
#base_properties ⇒ Object
1397 |
# File 'lib/axn/internal/reflection/schema.rb', line 1397 def base_properties = type_schema[:properties] || {} |
#in_items? ⇒ Boolean
1395 |
# File 'lib/axn/internal/reflection/schema.rb', line 1395 def in_items? = in_items |