Class: ApplicationSerializer
- Inherits:
-
ActiveModel::Serializer
- Object
- ActiveModel::Serializer
- ApplicationSerializer
- Defined in:
- lib/generators/command/templates/application_serializer.rb
Overview
Uses russian doll technique
Instance Method Summary collapse
-
#serializable_hash ⇒ Object
Cache individual Hash objects before serialization This also makes them available to associated serializers.
-
#to_json(*args) ⇒ Object
Cache entire JSON string.
Instance Method Details
#serializable_hash ⇒ Object
Cache individual Hash objects before serialization This also makes them available to associated serializers
14 15 16 17 18 |
# File 'lib/generators/command/templates/application_serializer.rb', line 14 def serializable_hash Rails.cache.fetch (self.class.to_s.underscore, cache_key, 'serilizable-hash') do super end end |
#to_json(*args) ⇒ Object
Cache entire JSON string
6 7 8 9 10 |
# File 'lib/generators/command/templates/application_serializer.rb', line 6 def to_json(*args) Rails.cache.fetch (self.class.to_s.underscore, cache_key, 'to-json') do super end end |