W3cubDocs

/Crystal

class YAML::ParseContext

Overview

Parsing context that holds anchors and what they refer to.

When implementing new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) to deserialize an object from a node, Reference types must invoke both #read_alias and #record_anchor in order to support parsing recursive data structures.

  • #read_alias must be invoked before an instance is created
  • #record_anchor must be invoked after an instance is created and before its members are deserialized.

Defined in:

yaml/parse_context.cr

Constructors

Instance Method Summary

Constructor Detail

def self.newSource

Instance Method Detail

def read_alias(node, type : T.class, &) forall TSource

Tries to read an alias from node of type T. Invokes the block if successful, and invokers must return this object instead of deserializing their members.

def read_alias?(node, type : T.class, &) forall TSource

Similar to #read_alias but doesn't raise if an alias exists but an instance of type T isn't associated with the current anchor.

def record_anchor(node, object : T) : Nil forall TSource

Associates an object with an anchor.

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/YAML/ParseContext.html