rest_framework 0.7.9 → 0.7.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6a9bc78fae632a2c86426c523fbce432cb85904ea661219032d6e4352ab16ea
4
- data.tar.gz: f202cd11931c54fada9e8dd1e3af1dd9344b2a883dd5cb00ebf45708afdd365c
3
+ metadata.gz: 71c34ceb6bb68b3b9ea023e62fa2fc5d6ea3382fad38a94d32c235d66fe87281
4
+ data.tar.gz: d4300ef78a151d25f0d67b74df5d1d6584e0452e3ff3e719ddae41ece6aa3cf7
5
5
  SHA512:
6
- metadata.gz: 8759e8295bb59715cd8aab800bd6a158a17422bee4adea2fc5d77c8517d44a92b6ff4a771a2c10a021162f5c582b4853a9d1ebd2bb5cc4e29468f3a6b061460b
7
- data.tar.gz: 46e0b4693c1166e774f00a25f0f9378f2702e0449f87b2e808ea16d395b1df98ae5e564fff198daf53b6d3e0ba3352a12232a2a7f6962a74ea578b0f9a77c09d
6
+ metadata.gz: ce6946077715c32b8e7f5d08c8df1b1d1ae9f7b714c5ed8411a4086ba5fe8a96328179fdf7685c26b7fce7d8d208dba1045d499952b4980c0a3cfac71364cc07
7
+ data.tar.gz: a4da9fd65a971ddad1e596927d95ff7088fbd6429df007941ef2c990ab08df19d8891abb22166a5cc13ae155438cfc04aa63868060ea4f2c647023a707f45a71
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.9
1
+ 0.7.10
@@ -127,7 +127,7 @@ module RESTFramework::BaseModelControllerMixin
127
127
  config = self.field_config&.dig(f.to_sym) || {}
128
128
 
129
129
  # Default sub-fields if field is an association.
130
- if ref = self.get_model.reflections[f]
130
+ if ref = self.get_model.reflections[f.to_s]
131
131
  if ref.polymorphic?
132
132
  columns = {}
133
133
  else
@@ -218,7 +218,7 @@ module RESTFramework::BaseModelControllerMixin
218
218
  if self.permit_id_assignment
219
219
  if ref.collection?
220
220
  metadata[:id_field] = "#{f.singularize}_ids"
221
- else
221
+ elsif ref.belongs_to?
222
222
  metadata[:id_field] = "#{f}_id"
223
223
  end
224
224
  end
@@ -396,26 +396,29 @@ module RESTFramework::BaseModelControllerMixin
396
396
  return @allowed_parameters = nil unless fields = self.get_fields
397
397
 
398
398
  # For fields, automatically add `_id`/`_ids` and `_attributes` variations for associations.
399
- return @allowed_parameters = fields.map { |f|
399
+ id_variations = []
400
+ variations = {}
401
+ @allowed_parameters = fields.map { |f|
400
402
  f = f.to_s
401
403
  next f unless ref = self.class.get_model.reflections[f]
402
404
 
403
- variations = [f]
404
-
405
405
  if self.class.permit_id_assignment
406
406
  if ref.collection?
407
- variations << "#{f.singularize}_ids"
408
- else
409
- variations << "#{f}_id"
407
+ variations["#{f.singularize}_ids"] = []
408
+ elsif ref.belongs_to?
409
+ id_variations << "#{f}_id"
410
410
  end
411
411
  end
412
412
 
413
413
  if self.class.permit_nested_attributes_assignment
414
- variations << "#{f}_attributes"
414
+ variations["#{f}_attributes"] = self.class.get_field_config(f)[:sub_fields] || {}
415
415
  end
416
416
 
417
- next variations
417
+ next f
418
418
  }.flatten
419
+ @allowed_parameters += id_variations
420
+ @allowed_parameters << variations
421
+ return @allowed_parameters
419
422
  end
420
423
 
421
424
  # 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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory N. Schmit