intridea/grape — Issue #71: Entities raise exceptions with ActiveSupport installed
Author: stouset
Created: 2011-11-12 17:11:35+00:00
State: open

```ruby
require 'active_support/core_ext'

...

get '/foo' do
present [(class Foo; self; end).new], :with => Grape::Entity
end
```

The above (entity-wrapping an Array) results in a stacktrace.

```TypeError: can't convert nil into Hash
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/entity.rb:121:in `merge'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/entity.rb:121:in `serializable_hash'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:46:in `block in encode'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:60:in `check_for_circular_references'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:45:in `encode'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:190:in `block in encode_json'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:190:in `map'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:190:in `encode_json'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:46:in `block in encode'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:60:in `check_for_circular_references'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:45:in `encode'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/json/encoding.rb:30:in `encode'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/gems/activesupport-3.0.0/lib/active_support/core_ext/object/to_json.rb:20:in `to_json'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:117:in `encode_json'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/formatter.rb:79:in `call'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/formatter.rb:79:in `block in after'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/formatter.rb:78:in `collect'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/formatter.rb:78:in `after'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:26:in `call!'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:19:in `call'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:25:in `call!'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:19:in `call'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/error.rb:44:in `block in call!'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/error.rb:43:in `catch'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/error.rb:43:in `call!'
/Users/stouset/.rbenv/versions/1.9.3-p0/gemsets/zeevex-accountant/bundler/gems/grape-883295cf0856/lib/grape/middleware/base.rb:19:in `call'
```

I fixed this locally by rewriting the `serializable_hash` method to set `runtime_options ||= {}`, since it may be passed in as `nil`.