codenoble / cache-crispies

Speedy Rails JSON serialization with built-in caching
MIT License
156 stars 16 forks source link

Allow overriding serializer key with empty value #49

Closed floriandejonckheere closed 1 year ago

floriandejonckheere commented 1 year ago

Allow specifying an empty key in the controller, overriding a key set (or automatically generated) in the serializer class.

class PersonSerializer < CacheCrispies::Base
  key :person

  serialize :name
end

cache_render Person.new(name: "John Doe")
# => { person: { name: "John Doe" } }

cache_render Person.new(name: "John Doe"), key: nil
# => { name: "John Doe" }
adamcrown commented 1 year ago

Makes sense. Thanks for the PR!

adamcrown commented 1 year ago

I just released version 1.4.0. Thanks again!