module

Hwaro::Utils::Nesting

Constants

MAX_VALUE_DEPTH = 512

Same value as TOML::Parser::HWARO_MAX_NESTING and Crystal's JSON::PullParser/YAML MAX_NESTING. Any document that parses at all is already capped at 512 levels of real nesting, so this can only fire on a cycle — no valid input reaches it.

Class methods

check!(depth : Int32) : Nil

Raises once the walk is deeper than any real document can be.

Source
validate!(value : YAML::Any, depth : Int32 = 0) : Nil

Validate a YAML::Any subtree before handing it to a serializer that has no depth parameter of its own — YAML::Any#to_json and #to_s both recurse the raw graph, so on a cyclic value they blow the stack where a depth thread would have raised. Walk it first; the walk is bounded, the serializer that follows is then known to be too.

Source

Nested types