rails_json_serializer 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serializer/concern.rb +20 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b2c3e2e7b905079dce0ddbbf0b48028a36d68b10da5ab4278d597eaf70713a
|
4
|
+
data.tar.gz: 9e730e031d3b73eaa9fb27f838fb4f6761256755281257cb99db9b3b15659ded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70bba5bd544d0d2e95ae9bec6b5c4762eec9b036fe750a0777ef7663903b9894e05f8c2fcb703f2d021023594132ab2d6d6cecea4a1d8e2c12a3b72dd1c1d7e2
|
7
|
+
data.tar.gz: 27594e6cb05baefffd863555b226f2b672a3c84dcebbb661672266cba0ede47181efe39e702b7a44872582b0a873d5957e91200b4e8a1c6ef34aaf3f76abba98
|
data/lib/serializer/concern.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Serializer
|
2
|
+
DELETE_MATCHED_SUPPORTED_CACHE_TYPES = [:memory_store, :file_store]
|
2
3
|
module Concern
|
3
4
|
# ActiveSupport extend src: https://stackoverflow.com/questions/2328984/rails-extending-activerecordbase
|
4
5
|
extend ActiveSupport::Concern
|
@@ -132,10 +133,12 @@ module Serializer
|
|
132
133
|
|
133
134
|
# Issue with inheritting classes caching the serializer data from queries in super classes.
|
134
135
|
# Only on the rails server, not the console strangely.
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
136
|
+
if DELETE_MATCHED_SUPPORTED_CACHE_TYPES.include?(Rails.configuration.cache_store)
|
137
|
+
serializer_query_names.each do |query_name|
|
138
|
+
cache_key_prefix = /#{subclass.name}_____#{query_name}___(\d+)/
|
139
|
+
puts "Deleting cache here: Rails.cache.delete_matched(#{cache_key_prefix})"
|
140
|
+
Rails.cache.delete_matched(cache_key_prefix)
|
141
|
+
end
|
139
142
|
end
|
140
143
|
end
|
141
144
|
else
|
@@ -146,13 +149,20 @@ module Serializer
|
|
146
149
|
end
|
147
150
|
|
148
151
|
# Class defined clear serializer
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
if DELETE_MATCHED_SUPPORTED_CACHE_TYPES.include?(Rails.configuration.cache_store)
|
153
|
+
def clear_serializer_cache
|
154
|
+
self.get_cumulatively_inherited_serializer_query_list.each do |query_name|
|
155
|
+
cache_key_prefix = /#{self.name}_____#{query_name}___(\d+)/
|
156
|
+
Rails.logger.info "Serializer: CLEARING CACHE KEY Prefix: #{cache_key_prefix}" if Serializer.configuration.debug
|
157
|
+
Rails.cache.delete_matched(cache_key_prefix)
|
158
|
+
end
|
159
|
+
return true
|
160
|
+
end
|
161
|
+
else
|
162
|
+
def clear_serializer_cache
|
163
|
+
puts "Not supported by rails cache store: #{Rails.configuration.cache_store}. Supported: #{DELETE_MATCHED_SUPPORTED_CACHE_TYPES}"
|
164
|
+
return false
|
154
165
|
end
|
155
|
-
return true
|
156
166
|
end
|
157
167
|
|
158
168
|
# Can override the query, using the options. ex: {json_query_override: :tiny_children_serializer_query}
|