rest_framework 0.6.3 → 0.6.4

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: 9310e248327d207a68953d1f629bb9c094c860ee7fe50f1ada4cb87e88e1da43
4
- data.tar.gz: c7ffe0f8ef8bf0c0f26b7d918cccbd91c9b1650f144c7ba071d9f9db0c2b4a2b
3
+ metadata.gz: 58fa867a9eed508be6ef78687d445cb5f3c0dc8cf0c004d8a8eab7f003f622cb
4
+ data.tar.gz: da285af9bf75273dcd864362d57ada399cc876e0e28767e546a89d1a8f280d28
5
5
  SHA512:
6
- metadata.gz: 49c1bd1aa35b97b3543ffe3a66b1eb8a19fe339f996483071be1cb6817aa3f8d4848ff90f0b5bd7e20769c9c1c028f605de1e8251cb80bd2fcfb979ec10de2bd
7
- data.tar.gz: 1c5e9ef47b970fd883023ac2eb11b3febabfb83d929908de28553b46a668c2136286bef4873f489e5fa263959cbf33a8b8cecef6bce7ace29926983566cad94a
6
+ metadata.gz: 480e49357afb571538b0f5ec730eff04a0dc326ca4d9e93e9bbba7a60571c3dc2b09ddd3cbfa4ca2dec734e4de5de6faec542e5d06d5e9674e2c492575d2b450
7
+ data.tar.gz: 138e532ede2fdd207a557edf0cc8fd89f24eceb782b251adf107c3e445ad2e0a32d69fa66475d1215321f6085a953cce98f586284e39d207d453727e66f8a714
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.6.4
@@ -51,6 +51,10 @@ module RESTFramework::BaseControllerMixin
51
51
  serialize_to_xml: true,
52
52
  singleton_controller: nil,
53
53
  skip_actions: nil,
54
+
55
+ # Helper to disable serializer adapters by default, mainly introduced because Active Model
56
+ # Serializers will do things like serialize `[]` into `{"":[]}`.
57
+ disable_adapters_by_default: true,
54
58
  }.each do |a, default|
55
59
  next if base.respond_to?(a)
56
60
 
@@ -138,6 +142,11 @@ module RESTFramework::BaseControllerMixin
138
142
  json_kwargs = kwargs.delete(:json_kwargs) || {}
139
143
  xml_kwargs = kwargs.delete(:xml_kwargs) || {}
140
144
 
145
+ # Do not use any adapters by default, if configured.
146
+ if self.class.disable_adapters_by_default && !kwargs.key?(:adapter)
147
+ kwargs[:adapter] = nil
148
+ end
149
+
141
150
  # Raise helpful error if payload is nil. Usually this happens when a record is not found (e.g.,
142
151
  # when passing something like `User.find_by(id: some_id)` to `api_response`). The caller should
143
152
  # actually be calling `find_by!` to raise ActiveRecord::RecordNotFound and allowing the REST
@@ -177,14 +177,13 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
177
177
  only = only.split(",").map(&:strip).map(&:to_sym)
178
178
 
179
179
  unless only.empty?
180
- # For the `except` part of the serializer, we need to append any columns not in `only`.
181
- model = @controller.get_model
182
- except_cols = model&.column_names&.map(&:to_sym)&.reject { |c| c.in?(only) }
183
-
184
180
  # Filter `only`, `except` (additive), `include`, and `methods`.
185
181
  if cfg[:only]
186
182
  cfg[:only] = self.class.filter_subcfg(cfg[:only], fields: only, only: true)
187
183
  elsif cfg[:except]
184
+ # For the `except` part of the serializer, we need to append any columns not in `only`.
185
+ model = @controller.get_model
186
+ except_cols = model&.column_names&.map(&:to_sym)&.reject { |c| c.in?(only) }
188
187
  cfg[:except] = self.class.filter_subcfg(cfg[:except], fields: except_cols, add: true)
189
188
  else
190
189
  cfg[:only] = only
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.6.3
4
+ version: 0.6.4
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-09-16 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails