rest_framework 0.8.9 → 0.8.10
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/controller_mixins/models.rb +6 -2
- data/lib/rest_framework/serializers.rb +4 -1
- 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: 213a37736ca78073859451dcc69b9dc7b17210087cb4250b454812c6de7c1a7c
|
4
|
+
data.tar.gz: 5392170651a45a187730ad8bf1355226569644c2732ef78c0919e778a927f323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b00876f3c2ca1fdb6beeb290c38774b13fe0b1549d19f00084537f0e8b42c43b6d716f79a3a60835172b59479756b3c9ffd6c17895be6be4fd16ebf3296c4f8c
|
7
|
+
data.tar.gz: f24eaf37f5da6a5abf340e63d1a3cd9514b5f4bc610563c27040b14a9b2698a8110955a1bb7ce58f6f52df23e632408e4c4194d37a84c8f385f4bc9facbf395d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.10
|
@@ -113,7 +113,11 @@ module RESTFramework::BaseModelControllerMixin
|
|
113
113
|
|
114
114
|
# Get a field's config, including defaults.
|
115
115
|
def get_field_config(f)
|
116
|
-
|
116
|
+
f = f.to_sym
|
117
|
+
@_get_field_config ||= {}
|
118
|
+
return @_get_field_config[f] if @_get_field_config[f]
|
119
|
+
|
120
|
+
config = self.field_config&.dig(f) || {}
|
117
121
|
|
118
122
|
# Default sub-fields if field is an association.
|
119
123
|
if ref = self.get_model.reflections[f.to_s]
|
@@ -137,7 +141,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
137
141
|
}.to_h.compact.presence
|
138
142
|
end
|
139
143
|
|
140
|
-
return config.compact
|
144
|
+
return @_get_field_config[f] = config.compact
|
141
145
|
end
|
142
146
|
|
143
147
|
# Get metadata about the resource's fields.
|
@@ -220,12 +220,15 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
220
220
|
methods = []
|
221
221
|
serializer_methods = {}
|
222
222
|
fields.each do |f|
|
223
|
+
field_config = @controller.class.get_field_config(f)
|
224
|
+
next if field_config[:write_only]
|
225
|
+
|
223
226
|
if f.in?(@model.column_names)
|
224
227
|
columns << f
|
225
228
|
elsif ref = @model.reflections[f]
|
226
229
|
sub_columns = []
|
227
230
|
sub_methods = []
|
228
|
-
|
231
|
+
field_config[:sub_fields].each do |sf|
|
229
232
|
if !ref.polymorphic? && sf.in?(ref.klass.column_names)
|
230
233
|
sub_columns << sf
|
231
234
|
else
|
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.8.
|
4
|
+
version: 0.8.10
|
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: 2023-02-
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|