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



46
47
48
49
50
51
52
# File 'lib/view_model/active_record/cache/cacheable_view.rb', line 46

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