nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 334 forks source link

Use empty hash as default cache options #637

Closed infertux closed 9 years ago

infertux commented 9 years ago

It's a hash of options and it makes more sense to default with a hash as well.

Moreover, it fixes an issue I'm having where the readthis Gem expects a hash at https://github.com/sorentwo/readthis/blob/f2bf22550958ad0232d6537e3029127c8339a82f/lib/readthis/cache.rb#L148


That said, I'm not sure whether this should be fixed in Rabl since ActiveSupport::Cache::Store uses nil as the default. Please let me know if you reckon readthis should handle the nil case instead and I'll send a PR there.

infertux commented 9 years ago

Partial backtrace FYI:

NoMethodError - undefined method `[]' for nil:NilClass:
  readthis (0.6.2) lib/readthis/cache.rb:149:in `fetch'
  rabl (0.11.6) lib/rabl/cache_engine.rb:18:in `fetch'
  rabl (0.11.6) lib/rabl/helpers.rb:143:in `fetch_result_from_cache'
  rabl (0.11.6) lib/rabl/engine.rb:385:in `cache_results'
  rabl (0.11.6) lib/rabl/engine.rb:47:in `render'
  [...]
infertux commented 9 years ago

Thanks :smile:

infertux commented 9 years ago

Any chance to push a release with this fix to RubyGems @nesquena? Thanks.

nesquena commented 8 years ago

@infertux yep, pushed 0.11.7 with your changes. Thanks! Please feel free to make any other improvements on rabl as you find you can and I am always happy to push new releases.

infertux commented 8 years ago

Thanks a lot @nesquena :)