Module: ViewModel::ActiveRecord::Cache::CacheableView

Extended by:
ActiveSupport::Concern
Defined in:
lib/view_model/active_record/cache/cacheable_view.rb

Overview

Concern providing caching configuration and lookup on viewmodels.

Defined Under Namespace

Classes: CacheClearer

Instance Method Summary collapse

Instance Method Details

#after_deserialize(deserialize_context:, changes:) ⇒ Object

Clear the cache if the view or its nested children were changed during deserialization



54
55
56
57
58
59
60
# File 'lib/view_model/active_record/cache/cacheable_view.rb', line 54

def after_deserialize(deserialize_context:, changes:)
  super if defined?(super)

  if !changes.new? && changes.changed_nested_tree?
    CacheClearer.new(self.class.viewmodel_cache, id).add_to_transaction
  end
end