psych
psych copied to clipboard
Move the responsibility of safe loading to Node
This change moves the responsibility of safely loading a YAML tree from an internal detail of Psych.safe_load into Psych::Nodes::Node.
The advantage of this is that you can now more easily safely load trees that you're working on without replicating the safety constraints of Psych.safe_load. The delegation of responsibilities also now matches for safely and unsafely loading a tree.
I opted for two choices to make the diff smaller:
- I left all of the documentation on
Psych.safe_loadinstead of moving it toPsych::Nodes::Node#to_safe_ruby. The main reason I chose to do so is thatPsych.safe_loadis the most likely entry point into using Psych for most people, so having the documentation on that method makes sense. - I delegated responsibility for the default arguments to
Psych::Nodes::Noderather than duplicating them. The reason I chose to do this was to reduce the chance of two lists of arguments becoming unsynchronized. Additionally, since the behavior actually belongs toPsych::Nodes::Nodenow, it's the only place that can have the defaults set for all use cases.