rails_json_serializer 1.0.0 → 1.1.0
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 +4 -4
- data/lib/serializer/concern.rb +14 -3
- 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: 1979a6763434dbcb97197b96e8b6d063e57e7a1e1661f73aff7669ad0014d0e3
|
4
|
+
data.tar.gz: '0280285eefc66726612611b12df19d190a7ed1421393394a6c669a93ab33fd15'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 681b0f1e1b1856859676747640f6829437cc613987ffb1a60939254f4492c1c83bbe49ebb96f8eba764d3b5da8bf47b337c44e2ffe9b0893188d97c3316ff999
|
7
|
+
data.tar.gz: 48152e760af615c8ec8b399e7a8a8ea72cdb0d663d85bfac9d242d1df01a4c2c0cba95f0629664e01cb0213c2ce82d321c3cb33ff5ee217b426cc296cc16d0fc
|
data/lib/serializer/concern.rb
CHANGED
@@ -5,8 +5,8 @@ module Serializer
|
|
5
5
|
|
6
6
|
# START MODEL INSTANCE METHODS
|
7
7
|
def clear_serializer_cache
|
8
|
-
if self.class.const_defined?("
|
9
|
-
serializer_klass = "#{self.class.name}
|
8
|
+
if self.class.const_defined?("SerializerMethods")
|
9
|
+
serializer_klass = "#{self.class.name}::SerializerMethods".constantize
|
10
10
|
serializer_klass.public_instance_methods.each do |query_name|
|
11
11
|
cache_key = "#{self.class.name}_____#{query_name}___#{self.id}"
|
12
12
|
Rails.logger.info "Serializer: CLEARING CACHE KEY: #{cache_key}" if Serializer.configuration.debug
|
@@ -14,7 +14,14 @@ module Serializer
|
|
14
14
|
end
|
15
15
|
return true
|
16
16
|
else
|
17
|
-
|
17
|
+
if Serializer.configuration.debug
|
18
|
+
Rails.logger.info(
|
19
|
+
"""
|
20
|
+
Serializer: Class #{self.class.name} does not have the serializer module #{self.class.name}Serializer defined.
|
21
|
+
Nor was it defined on an inheriting class.
|
22
|
+
"""
|
23
|
+
)
|
24
|
+
end
|
18
25
|
return nil
|
19
26
|
end
|
20
27
|
end
|
@@ -98,6 +105,10 @@ module Serializer
|
|
98
105
|
subclass.send(:extend, serializer_klass::SerializerMethods)
|
99
106
|
# Inject class methods that has queries
|
100
107
|
subclass.send(:extend, serializer_klass)
|
108
|
+
# Injecting the Serializer Methods as a namespaced class of the rails class, so we can have
|
109
|
+
# access to the list of methods to clear their cache.
|
110
|
+
# 'Class Name + Serializer' does not work with inheritence.
|
111
|
+
subclass.const_set('SerializerMethods', serializer_klass::SerializerMethods.dup)
|
101
112
|
else
|
102
113
|
Rails.logger.info "Serializer: #{serializer_klass.name} was not a Module as expected" if Serializer.configuration.debug
|
103
114
|
end
|