rest_framework 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rest_framework/serializers.rb +19 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4670a5de96eba75413576ebb961297e0e45d3a95bb7e979ebb9b1a13cdaed46b
|
4
|
+
data.tar.gz: 807edfa466079b3a4031feb738b43eeb10cffacb8821fa54d4b02145dc86ab4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75d14784e343ea98af7048c4ac7deb975b2090ace55bfbebba46f7cb7b59149d99349296faff7d7c746a8e1db757343ea8cc70c5297425b3f7463c088c8c3ae
|
7
|
+
data.tar.gz: 8a80fa46d1f1f68781fd0b13ea5586d7053e7cb62f8829c496e031f66f6492a05053b0812e68c9bf27f2a1852dd77b4b0e4526298ca0d62d11be2cae851f1172
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -85,7 +85,7 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
85
85
|
|
86
86
|
# Helper to filter (mutate) a single subconfig for specific keys.
|
87
87
|
def self.filter_subconfig(subconfig, except, additive: false)
|
88
|
-
return subconfig
|
88
|
+
return subconfig if !subconfig && !additive
|
89
89
|
|
90
90
|
if subconfig.is_a?(Array)
|
91
91
|
subconfig = subconfig.map(&:to_sym)
|
@@ -96,8 +96,19 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
96
96
|
subconfig -= except
|
97
97
|
end
|
98
98
|
elsif subconfig.is_a?(Hash)
|
99
|
-
|
100
|
-
|
99
|
+
# Additive doesn't make sense in a hash context since we wouldn't know the values.
|
100
|
+
unless additive
|
101
|
+
subconfig.symbolize_keys!
|
102
|
+
subconfig.reject! { |k, _v| k.in?(except) }
|
103
|
+
end
|
104
|
+
elsif !subconfig
|
105
|
+
else # Subconfig is a single element (assume string/symbol).
|
106
|
+
subconfig = subconfig.to_sym
|
107
|
+
if subconfig.in?(except)
|
108
|
+
subconfig = [] unless additive
|
109
|
+
elsif additive
|
110
|
+
subconfig = [subconfig, *except]
|
111
|
+
end
|
101
112
|
end
|
102
113
|
|
103
114
|
return subconfig
|
@@ -108,7 +119,7 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
108
119
|
return config unless @controller
|
109
120
|
|
110
121
|
except_query_param = @controller.class.try(:native_serializer_except_query_param)
|
111
|
-
if except = @controller.request.query_parameters[except_query_param]
|
122
|
+
if except = @controller.request.query_parameters[except_query_param].presence
|
112
123
|
except = except.split(",").map(&:strip).map(&:to_sym)
|
113
124
|
|
114
125
|
unless except.empty?
|
@@ -116,10 +127,10 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
116
127
|
config = config.deep_dup
|
117
128
|
|
118
129
|
# Filter `only`, `except` (additive), `include`, and `methods`.
|
119
|
-
self.class.filter_subconfig(config[:only], except)
|
120
|
-
self.class.filter_subconfig(config[:except], except, additive: true)
|
121
|
-
self.class.filter_subconfig(config[:include], except)
|
122
|
-
self.class.filter_subconfig(config[:methods], except)
|
130
|
+
config[:only] = self.class.filter_subconfig(config[:only], except)
|
131
|
+
config[:except] = self.class.filter_subconfig(config[:except], except, additive: true)
|
132
|
+
config[:include] = self.class.filter_subconfig(config[:include], except)
|
133
|
+
config[:methods] = self.class.filter_subconfig(config[:methods], except)
|
123
134
|
end
|
124
135
|
end
|
125
136
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory N. Schmit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|