rest_framework 0.7.9 → 0.7.11
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/VERSION +1 -1
- data/lib/rest_framework/controller_mixins/models.rb +22 -14
- data/lib/rest_framework/filters.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd88c76d9f83658ca09087b8931cec7ea569b4df5675c4ae8e21045dedf8ab2
|
4
|
+
data.tar.gz: 72d0a0a1f8bc086fbd69713d825ed0aedc93540ab1d114d0843cb5e99aca6696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58f0e75004fc57e10366ecdd681a1729c88280514a71023585a49690ded6ee3a7947c9271f212b012412581ac62e3d294a2d955eda833e8b5dcce71bb0410ca
|
7
|
+
data.tar.gz: 20022bf8d6171d37f118693ccc50e419a885a17e7d8455833b3399387cbeb534c3e19834110b797aca0066f40d6fba0bf765b0aee4644b4a55b75ed4fa7cf9d4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.11
|
@@ -50,6 +50,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
50
50
|
# Options for association assignment.
|
51
51
|
permit_id_assignment: true,
|
52
52
|
permit_nested_attributes_assignment: true,
|
53
|
+
allow_all_nested_attributes: false,
|
53
54
|
|
54
55
|
# Option for `recordset.create` vs `Model.create` behavior.
|
55
56
|
create_from_recordset: true,
|
@@ -127,7 +128,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
127
128
|
config = self.field_config&.dig(f.to_sym) || {}
|
128
129
|
|
129
130
|
# Default sub-fields if field is an association.
|
130
|
-
if ref = self.get_model.reflections[f]
|
131
|
+
if ref = self.get_model.reflections[f.to_s]
|
131
132
|
if ref.polymorphic?
|
132
133
|
columns = {}
|
133
134
|
else
|
@@ -218,7 +219,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
218
219
|
if self.permit_id_assignment
|
219
220
|
if ref.collection?
|
220
221
|
metadata[:id_field] = "#{f.singularize}_ids"
|
221
|
-
|
222
|
+
elsif ref.belongs_to?
|
222
223
|
metadata[:id_field] = "#{f}_id"
|
223
224
|
end
|
224
225
|
end
|
@@ -386,36 +387,43 @@ module RESTFramework::BaseModelControllerMixin
|
|
386
387
|
# Get a list of parameters allowed for the current action. By default we do not fallback to
|
387
388
|
# columns so arbitrary fields can be submitted if no fields are defined.
|
388
389
|
def get_allowed_parameters
|
389
|
-
return @
|
390
|
+
return @_get_allowed_parameters if defined?(@_get_allowed_parameters)
|
390
391
|
|
391
|
-
@
|
392
|
+
@_get_allowed_parameters = self._get_specific_action_config(
|
392
393
|
:allowed_action_parameters,
|
393
394
|
:allowed_parameters,
|
394
395
|
)
|
395
|
-
return @
|
396
|
-
return @
|
396
|
+
return @_get_allowed_parameters if @_get_allowed_parameters
|
397
|
+
return @_get_allowed_parameters = nil unless fields = self.get_fields
|
397
398
|
|
398
399
|
# For fields, automatically add `_id`/`_ids` and `_attributes` variations for associations.
|
399
|
-
|
400
|
+
id_variations = []
|
401
|
+
variations = {}
|
402
|
+
@_get_allowed_parameters = fields.map { |f|
|
400
403
|
f = f.to_s
|
401
404
|
next f unless ref = self.class.get_model.reflections[f]
|
402
405
|
|
403
|
-
variations = [f]
|
404
|
-
|
405
406
|
if self.class.permit_id_assignment
|
406
407
|
if ref.collection?
|
407
|
-
variations
|
408
|
-
|
409
|
-
|
408
|
+
variations["#{f.singularize}_ids"] = []
|
409
|
+
elsif ref.belongs_to?
|
410
|
+
id_variations << "#{f}_id"
|
410
411
|
end
|
411
412
|
end
|
412
413
|
|
413
414
|
if self.class.permit_nested_attributes_assignment
|
414
|
-
|
415
|
+
if self.class.allow_all_nested_attributes
|
416
|
+
variations["#{f}_attributes"] = {}
|
417
|
+
else
|
418
|
+
variations["#{f}_attributes"] = self.class.get_field_config(f)[:sub_fields]
|
419
|
+
end
|
415
420
|
end
|
416
421
|
|
417
|
-
next
|
422
|
+
next f
|
418
423
|
}.flatten
|
424
|
+
@_get_allowed_parameters += id_variations
|
425
|
+
@_get_allowed_parameters << variations
|
426
|
+
return @_get_allowed_parameters
|
419
427
|
end
|
420
428
|
|
421
429
|
# Get the configured serializer class, or `NativeSerializer` as a default.
|
@@ -33,7 +33,7 @@ class RESTFramework::ModelFilter < RESTFramework::BaseFilter
|
|
33
33
|
field, sub_field = match[1..2]
|
34
34
|
next false unless field.in?(fields)
|
35
35
|
|
36
|
-
sub_fields = @controller.class.get_field_config(field)[:sub_fields]
|
36
|
+
sub_fields = @controller.class.get_field_config(field)[:sub_fields] || []
|
37
37
|
next sub_field.in?(sub_fields)
|
38
38
|
end
|
39
39
|
|
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.7.
|
4
|
+
version: 0.7.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory N. Schmit
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -62,7 +62,7 @@ licenses:
|
|
62
62
|
metadata:
|
63
63
|
homepage_uri: https://rails-rest-framework.com
|
64
64
|
source_code_uri: https://github.com/gregschmit/rails-rest-framework
|
65
|
-
post_install_message:
|
65
|
+
post_install_message:
|
66
66
|
rdoc_options: []
|
67
67
|
require_paths:
|
68
68
|
- lib
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubygems_version: 3.2.33
|
82
|
-
signing_key:
|
82
|
+
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: A framework for DRY RESTful APIs in Ruby on Rails.
|
85
85
|
test_files: []
|