class ApplicationSerializer

Uses russian doll technique

Public Instance Methods

serializable_hash() click to toggle source

Cache individual Hash objects before serialization This also makes them available to associated serializers

Calls superclass method
# File lib/generators/command/templates/application_serializer.rb, line 14
def serializable_hash
  Rails.cache.fetch expand_cache_key(self.class.to_s.underscore, cache_key, 'serilizable-hash') do
    super
  end
end
to_json(*args) click to toggle source

Cache entire JSON string

Calls superclass method
# File lib/generators/command/templates/application_serializer.rb, line 6
def to_json(*args)
  Rails.cache.fetch expand_cache_key(self.class.to_s.underscore, cache_key, 'to-json') do
    super
  end
end

Private Instance Methods

expand_cache_key(*args) click to toggle source
# File lib/generators/command/templates/application_serializer.rb, line 21
def expand_cache_key(*args)
  ActiveSupport::Cache.expand_cache_key args
end