简体   繁体   English

如何防止Ruby的.to_yaml使用引用?

[英]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. 在Rails控制台中调试东西时,我想防止.to_yamly帮助器为相同对象设置引用,因为这些引用使输出难以阅读。

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. 毕竟,它不是同一对象图,特别是它实际上不是您要序列化的对象图,而且我很确定YAML序列化器中没有选项可以将对象图序列化为不同对象图的表示形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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