drapergem/draper — pull request #565 by djhopper01 (2013-07-19 21:24:46+00:00)
Title: Unexpected behavior using to_json on a decorated object.

Hey guys,

First of all, thanks for the gem. We love it.

We had some unexpected behavior with draper and the `to_json` method. Basically, we were expecting it to behave like the following:

From a Rails 3.2.13 console.
```ruby
Task.include_root_in_json = true
=> true
task.to_json(only: :id)
=> "{\"task\":{\"id\":1}}"
Task.include_root_in_json = false
=> false
task.to_json(only: :id)
=> "{\"id\":1}"
```

But with a decorated object, we get this unexpected behavior:
```ruby
Task.include_root_in_json = true
=> true
task.decorate.to_json(only: :id)
=> "{\"task\":{\"id\":1}}"
Task.include_root_in_json = false
=> false
task.decorate.to_json(only: :id)
=> "{\"task\":{\"id\":1}}"
```

We have `include_root_in_json` set to false in an initializer like so:
```ruby
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end
```

We worked around the issue by delegating `to_json` inside the decorator. I tried to write a good failing test to illustrate the unexpected behavior. I saw #101 which mentioned a similar situation - any thoughts on this?