Class: Axn::Internal::ResolvedSubfields

Inherits:
Data
  • Object
show all
Defined in:
lib/axn/internal/resolved_subfields.rb

Overview

The canonical resolved-subfield artifact (PRO-2883): the SubfieldTree plus its derived {required, nullable} annotations and its dropped-deep-config verdict, built once from a class's declared configs and cached per class (see ContractForSubfields::ClassMethods#_resolved_subfields). Both annotations and dropped are Reflection::Schema's judgment over the tree, composed in here so Core:: reads either as a cheap reader on the runtime path rather than recomputing it. Deep-frozen before it is published, so the runtime hot path can never mutate it — and a benign first-call build race between threads just produces two identical values.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations

Returns:

  • (Object)

    the current value of annotations



15
16
17
# File 'lib/axn/internal/resolved_subfields.rb', line 15

def annotations
  @annotations
end

#droppedObject (readonly)

Returns the value of attribute dropped

Returns:

  • (Object)

    the current value of dropped



15
16
17
# File 'lib/axn/internal/resolved_subfields.rb', line 15

def dropped
  @dropped
end

#treeObject (readonly)

Returns the value of attribute tree

Returns:

  • (Object)

    the current value of tree



15
16
17
# File 'lib/axn/internal/resolved_subfields.rb', line 15

def tree
  @tree
end

Class Method Details

.build(field_configs, subfield_configs) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/axn/internal/resolved_subfields.rb', line 16

def self.build(field_configs, subfield_configs)
  tree = SubfieldTree.build(field_configs, Array(subfield_configs))
  annotations = Reflection::Schema.derive_annotations(tree.roots)
  dropped = Reflection::Schema.dropped_from_deep_paths(tree.deep_paths)
  _deep_freeze!(tree)
  new(tree:, annotations: annotations.freeze, dropped: dropped.freeze)
end

Instance Method Details

#indexObject



50
# File 'lib/axn/internal/resolved_subfields.rb', line 50

def index = tree.index

#rootsObject

Convenience delegators for the tree's members. dropped is its own Data member (above), not a delegator: the tree only collects the deep candidate pairs (deep_paths), and the drop verdict is what this artifact composes in on top, once, at build time.



49
# File 'lib/axn/internal/resolved_subfields.rb', line 49

def roots = tree.roots