Created
January 15, 2013 09:48
-
-
Save mrsimo/4537583 to your computer and use it in GitHub Desktop.
This used to work in ruby 1.8 In ruby 1.9 it creates an endless recursion. Where's my mistake?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestObject | |
(...) | |
## | |
# To be able to serialize objects they can't have Proc's, and @response/@request | |
# have them. So we remove them before actually doing the to_yaml. | |
def to_yaml(*args) | |
old_values = @response, @request | |
@response, @request = nil, nil | |
begin | |
super(*args) | |
ensure | |
@response, @request = old_values | |
end | |
end | |
end |
You're a star Jorge. That works wonderfully.
With all my google searches I couldn't find that anywhere. Guess I was searching for the wrong thing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In ruby you can specify what gets serialized in yaml like this:
another example
Maybe this can help?