awendt
awendt

Reputation: 13693

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?

Upvotes: 2

Views: 263

Answers (1)

Jörg W Mittag
Jörg W Mittag

Reputation: 369536

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.

Upvotes: 1

Related Questions