active_model_cachers 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8c49c9bc175d4ab55f5507cc4a6c4db006a099c90819e71788ced4b799d510f9
|
|
4
|
+
data.tar.gz: bb19f0043d46963c75b4ef71d30945c35156acb778b19d3f72e874b6c6dbdd15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 478355a8ee8fed5b1a25fcb6c2ef258888f6507c8e6bc74e98b9c559470b9475b750e69c7e03a7f77b05324cfc7927076e3c6173e08d0dbe4e4247283ab87011
|
|
7
|
+
data.tar.gz: c2029fb1379a12f03669b9a7dfa09858ab96a3cba755074ed1483e5a5239a890cd1c33dc9bfaf2973e7b76f5d1f42b166bb9a51b27e4c958d727d137d27437e4
|
data/.travis.yml
CHANGED
|
@@ -73,13 +73,6 @@ module ActiveModelCachers
|
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
def get_column_value_from_id(id, column, model)
|
|
77
|
-
return id if column == 'id'
|
|
78
|
-
model ||= cacher_at(id).peek_self if has_cacher?
|
|
79
|
-
return model.send(column) if model
|
|
80
|
-
return where(id: id).limit(1).pluck(column).first
|
|
81
|
-
end
|
|
82
|
-
|
|
83
76
|
@@column_value_cache = ActiveModelCachers::ColumnValueCache.new
|
|
84
77
|
def define_callback_for_cleaning_cache(class_name, column, foreign_key, on: nil, &clean)
|
|
85
78
|
ActiveSupport::Dependencies.onload(class_name) do
|
|
@@ -57,7 +57,8 @@ module ActiveModelCachers
|
|
|
57
57
|
def raw_to_cache_data(raw)
|
|
58
58
|
return NilObject if raw == nil
|
|
59
59
|
return FalseObject if raw == false
|
|
60
|
-
|
|
60
|
+
clean_ar_cache(raw.is_a?(Array) ? raw : [raw])
|
|
61
|
+
return raw_without_singleton_methods(raw)
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def cache_to_raw_data(cached_data)
|
|
@@ -75,5 +76,19 @@ module ActiveModelCachers
|
|
|
75
76
|
raw_to_cache_data(get_without_cache(binding))
|
|
76
77
|
end
|
|
77
78
|
end
|
|
79
|
+
|
|
80
|
+
def clean_ar_cache(models)
|
|
81
|
+
return if not models.first.is_a?(::ActiveRecord::Base)
|
|
82
|
+
models.each_with_index do |model, index|
|
|
83
|
+
model.send(:clear_aggregation_cache)
|
|
84
|
+
model.send(:clear_association_cache)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def raw_without_singleton_methods(raw)
|
|
89
|
+
return raw if raw.singleton_methods.empty?
|
|
90
|
+
return raw.class.find_by(id: raw.id) if raw.is_a?(::ActiveRecord::Base) # cannot marshal singleton, so load a new record instead.
|
|
91
|
+
return raw # not sure what to do with other cases
|
|
92
|
+
end
|
|
78
93
|
end
|
|
79
94
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_model_cachers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- khiav reoy
|
|
@@ -116,6 +116,7 @@ files:
|
|
|
116
116
|
- gemfiles/4.2.gemfile
|
|
117
117
|
- gemfiles/5.0.gemfile
|
|
118
118
|
- gemfiles/5.1.gemfile
|
|
119
|
+
- gemfiles/5.2.gemfile
|
|
119
120
|
- lib/active_model_cachers.rb
|
|
120
121
|
- lib/active_model_cachers/active_record/attr_model.rb
|
|
121
122
|
- lib/active_model_cachers/active_record/cacher.rb
|
|
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
152
|
version: '0'
|
|
152
153
|
requirements: []
|
|
153
154
|
rubyforge_project:
|
|
154
|
-
rubygems_version: 2.6
|
|
155
|
+
rubygems_version: 2.7.6
|
|
155
156
|
signing_key:
|
|
156
157
|
specification_version: 4
|
|
157
158
|
summary: Let you cache whatever you want with ease by providing cachers to active
|