rails_json_serializer 2.0.0 → 3.0.1
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/model_serializer.rb +14 -0
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dbc21fe6370943050869252bcb0dc1ad737ed58058d34dca1a0877d1f09adec
|
4
|
+
data.tar.gz: 5b8c6a68aab5c7c7f9b67bba5987f70004f73cec4071ccdda7cec0ab96725636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e9cb62478a5a225b3c56fd8e99e2cf9b1451542d4c170e494009ddba478ca9d50cd6f0e9ba927c17365ce583826bd7396d7341e37abbd2ad4736a80c54ce7a
|
7
|
+
data.tar.gz: 73b5b85f6c0644f61d9c1b66710774015db55e4a273b22379b4021a156c89ed2420df53b43941992efdb4f76fd8dc1860c89c405ec1a105694d8c83d629e830e
|
@@ -3,6 +3,15 @@ module ModelSerializer
|
|
3
3
|
def self.included klass
|
4
4
|
# START CLASS EVAL
|
5
5
|
klass.class_eval do
|
6
|
+
|
7
|
+
# Rails 5 has autoloading issues with modules. They will show as not defined, when available.
|
8
|
+
if Rails.env.development?
|
9
|
+
begin
|
10
|
+
"#{klass.name}Serializer".constantize
|
11
|
+
rescue NameError => e
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
6
15
|
if self.const_defined?("#{klass.name}Serializer")
|
7
16
|
serializer_klass = "#{klass.name}Serializer".constantize
|
8
17
|
serializer_query_names = serializer_klass.public_instance_methods
|
@@ -93,6 +102,11 @@ module ModelSerializer
|
|
93
102
|
|
94
103
|
|
95
104
|
klass.send(:define_method, :as_json) do |options = {}|
|
105
|
+
# We don't need to run this custom `as_json` multiple times, if defined on inherited class.
|
106
|
+
if options[:ran_serialization]
|
107
|
+
return super(options)
|
108
|
+
end
|
109
|
+
options[:ran_serialization] = true
|
96
110
|
# Not caching records that don't have IDs.
|
97
111
|
if !Serializer.configuration.disable_model_caching && self.id && options[:cache_key].present? && !(options.key?(:cache_for) && options[:cache_for].nil?)
|
98
112
|
cache_key = "#{self.class.name}_____#{options[:cache_key]}___#{self.id}"
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_json_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjamin.dana.software.dev@gmail.com
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-04-22 00:00:00.000000000 Z
|
@@ -14,30 +14,30 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '5.
|
33
|
+
version: '5.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '5.
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,8 +108,8 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.4'
|
111
|
-
description:
|
112
|
-
email:
|
111
|
+
description:
|
112
|
+
email:
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files: []
|
@@ -121,7 +121,7 @@ homepage: https://github.com/danabr75/rails_json_serializer
|
|
121
121
|
licenses:
|
122
122
|
- LGPL-3.0-only
|
123
123
|
metadata: {}
|
124
|
-
post_install_message:
|
124
|
+
post_install_message:
|
125
125
|
rdoc_options: []
|
126
126
|
require_paths:
|
127
127
|
- lib
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubygems_version: 3.0.8
|
140
|
-
signing_key:
|
140
|
+
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: An ActiveRecord JSON Serializer with supported caching and eager-loading
|
143
143
|
test_files: []
|