Module: CommonDataCaching
- Defined in:
- lib/common_data_caching.rb,
lib/common_data_caching/callbacks.rb,
lib/common_data_caching/class_methods.rb
Defined Under Namespace
Modules: Callbacks, ClassMethods
Class Method Summary
collapse
Class Method Details
.all_collections ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/common_data_caching.rb', line 12
def self.all_collections
versions.map do |entity, _version|
{
entity:,
objects: entity.constantize.common_data_cache_collection
}
end
end
|
.update_cache ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/common_data_caching.rb', line 21
def self.update_cache
Rails.application.eager_load!
models = ActiveRecord::Base.descendants
Rails.cache.delete('common-data-caching-versions')
models.each do |model|
next unless model.common_data_caching?
model.update_common_data_cache
model.update_common_data_cache_versions
end
end
|
.versions ⇒ Object
8
9
10
|
# File 'lib/common_data_caching.rb', line 8
def self.versions
Rails.cache.read('common-data-caching-versions') || {}
end
|