简体   繁体   中英

How can I prevent Ruby's .to_yaml from using references?

When debugging things in a Rails console, I'd like to prevent .to_yaml or the y helper to set up references for the same objects because these references make the output hard to read.

How can I do that?

I don't think you can do that. After all, it wouldn't be the same object graph, in particular, it wouldn't actually be the object graph you are serializing, and I'm pretty sure there is no option in the YAML serializer to serialize an object graph to a representation of a different object graph.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM