sferik/twitter — pull request #501 by trliner (2013-12-14 00:55:08+00:00)
Title: Implement #marshal_load and #marshal_dump for Twitter::Identity

In version 5.2.0 of the gem, marshaling tweets, users, and other objects that inherit from `Twitter::Identity` raises an exception, which makes certain things difficult, like storing them in `Rails.cache`.

Here's a simple example to reproduce the exception:

```ruby
require 'twitter'

client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end

tweet = client.user_timeline('gem').first
Marshal.dump(tweet)
# => TypeError: no _dump_data is defined for class Proc
```

This commit defines `marshal_dump` and `marshal_load` for the `Twitter::Identity` class. Unfortunately, the test I wrote doesn't fail without those methods because `rspec-mocks` redefines `Marshal.load`. So any feedback on how to write a better test (or on the pull request in general) would be appreciated.