rest_framework 0.8.9 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 638d5d849cf0f6a3b456c7fc6d1906263df776333bc754f38553aa45162a7be3
4
- data.tar.gz: 87bb5dcd4f65d3539d60bd80103be7d4dbafbf3f90c29200dadd144743edd19f
3
+ metadata.gz: 076db67d932800e57d2c166d757b60ea6e0d77df03da2385eddff8fd25886f76
4
+ data.tar.gz: d8b0fd131b50978e65b767d95a076f9592c8948a2708adff97e7971f84b0fbca
5
5
  SHA512:
6
- metadata.gz: e784ebdc889cf8c89e6fce1916e001d30c3a160b7093e5ff2de4903de1b86a577794dace867353d22d63d7caa4992e4e2ae95c1e4daf515395303eb032e84500
7
- data.tar.gz: e1eb1f492d928d9c062676f72621b753fbdbf1fbe22ca3b04c920808ed51b82f1dd96859852fcce0c202f7d3276079ccc96524cbfcf76e897aff030563f16be9
6
+ metadata.gz: f23d1835c49628c2b2f02521df2373438aabdb8ccb4fb12c3bd008cc757e3b660521c1eecf6d54fc92ad4f9b7c04881122acc9931c4d8847253cc78408e1e70d
7
+ data.tar.gz: 23dbfba94daee299e86a1e542d17b8b25bccd04989e569fee71731fac79c3996ac987a8ee28a58d4f489ddf1cf3a02d4774f45b022cbfaaeb9d796ddc6e71cb3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.9
1
+ 0.8.11
@@ -156,8 +156,8 @@ module RESTFramework::BaseControllerMixin
156
156
 
157
157
  # Alias `extra_actions` to `extra_collection_actions`.
158
158
  unless base.respond_to?(:extra_collection_actions)
159
- base.alias_method(:extra_collection_actions, :extra_actions)
160
- base.alias_method(:extra_collection_actions=, :extra_actions=)
159
+ base.singleton_class.alias_method(:extra_collection_actions, :extra_actions)
160
+ base.singleton_class.alias_method(:extra_collection_actions=, :extra_actions=)
161
161
  end
162
162
 
163
163
  # Skip CSRF since this is an API.
@@ -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
- config = self.field_config&.dig(f.to_sym) || {}
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
- @controller.class.get_field_config(f)[:sub_fields].each do |sf|
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.9
4
+ version: 0.8.11
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-27 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails