lostisland/sawyer

How to serialize a Sawyer::Resource object?

xystushi opened this issue · 5 comments

The new release of Octokit uses Sawyer to replace Hashie::Mash. I would like to cache some results as such pull requests. How should I serialize Sawyer::Resource objects and save them to disk?

I tried YAML and it complaint can't dump anonymous class. I also tried Marshal and it complaint singleton can't be dumped.

This should be fixed in c706f11, about to go out in 0.3.0.

Marshal serialization doesn't appear to be fixed. I tried to serialize a Sawyer::Resource object using Rail's 3.2.13 caching and it returns singleton can't be dumped

E.g. something like:

Rails.cache.fetch('response', :expires_in => 1.minutes) do
   response #Sawyer::Response obj
end

Yeah, we just fixed up YAML.dump. Patches welcome for fixing Marshal serialization.

I'm confused here, if this is not fixed properly why is this ticket closed still?!

I would like to cache some results as such pull requests. How should I serialize Sawyer::Resource objects and save them to disk?

The fix in c706f11 supports that. If you need support for Marshal, feel free to send over a patch.