Skip to content

Commit d96fc9d

Browse files
committed
fixup! [Untested] Add expire_cache_for_{insert,update,delete} methods
1 parent 27dac82 commit d96fc9d

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

lib/identity_cache/parent_model_expiration.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ def parent_expiration_entries
4141
ParentModelExpiration.install_pending_parent_expiry_hooks(cached_model)
4242
_parent_expiration_entries
4343
end
44-
45-
def check_for_unsupported_parent_expiration_entries
46-
return unless parent_expiration_entries.any?
47-
msg = +"Unsupported manual expiration of #{name} record that is embedded in parent associations:\n"
48-
parent_expiration_entries.each do |association_name, cached_associations|
49-
cached_associations.each do |parent_class, _only_on_foreign_key_change|
50-
msg << "- #{association_name}"
51-
end
52-
end
53-
raise msg
54-
end
5544
end
5645

5746
included do

lib/identity_cache/without_primary_index.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ def expire_cache_for_update(old_indexed_values, changes)
7575
alias_method :expire_cache_for_insert, :expire_cache_for_insert_or_delete
7676

7777
alias_method :expire_cache_for_delete, :expire_cache_for_insert_or_delete
78+
79+
private
80+
81+
def check_for_unsupported_parent_expiration_entries
82+
return unless parent_expiration_entries.any?
83+
msg = +"Unsupported manual expiration of #{name} record that is embedded in parent associations:\n"
84+
parent_expiration_entries.each do |association_name, cached_associations|
85+
cached_associations.each do |parent_class, _only_on_foreign_key_change|
86+
msg << "- #{association_name}"
87+
end
88+
end
89+
raise msg
90+
end
7891
end
7992
end
8093
end

0 commit comments

Comments
 (0)