rest_framework 0.8.0 → 0.8.2

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: 285ffa895b2f49246b09e98dce670236ee322c5323c4f715b7cd9e27675b8a48
4
- data.tar.gz: eead75ee8eaee0a62bcefe469e3957cedc480047b8819c4109c46c7ccd6f1372
3
+ metadata.gz: 2fa5466e302bc512ac4dc91b6f79c504bfcc88102be9282be9f55f33bad9a475
4
+ data.tar.gz: f940e69f12a56fc29ca69e10f81a33a5239bbbd8098966af308f2d4e7e2e1cbf
5
5
  SHA512:
6
- metadata.gz: aa0ddef34da4717063c928a48d30fd08d9629db792e7560d03b15ba6bd2b77532715bd76de4348ab27c03ca556d26e2bf6b8bf625a7d972aa11370b67fc387b0
7
- data.tar.gz: fc654b64c4cfe8e014047ee04a4c0eb60990a7d28491fe82686259c870098b27dcaa8a49e69f4fd650f50c51917ac9c5206fd1a49449a171d12816f615908b29
6
+ metadata.gz: 1089f785c9003daecb5c416f9122996526f585dd86639efd626bc90760f94d1c6c02eea72cb0c8cf3af67bd68feba9c1f520c8fce85827dec70ab22489b982c2
7
+ data.tar.gz: 833cbaf0e4ca413b0b96faa60eea950188764deebe6035501b2f28da1642aa173b442c13b89042d3c40fe4577651c1450b3a53ae240b99c9d3dd7321b139284f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.2
@@ -266,6 +266,13 @@ module RESTFramework::BaseModelControllerMixin
266
266
  # Update `required` if we find a presence validator.
267
267
  metadata[:required] = true if kind == :presence
268
268
 
269
+ # Resolve procs (and lambdas), and symbols for certain arguments.
270
+ if options[:in].is_a?(Proc)
271
+ options = options.merge(in: options[:in].call)
272
+ elsif options[:in].is_a?(Symbol)
273
+ options = options.merge(in: model.send(options[:in]))
274
+ end
275
+
269
276
  metadata[:validators] ||= {}
270
277
  metadata[:validators][kind] ||= []
271
278
  metadata[:validators][kind] << options
@@ -290,7 +297,7 @@ module RESTFramework::BaseModelControllerMixin
290
297
  def setup_delegation
291
298
  # Delegate extra actions.
292
299
  self.extra_actions&.each do |action, config|
293
- next unless config.is_a?(Hash) && config[:delegate]
300
+ next unless config.is_a?(Hash) && config.dig(:metadata, :delegate)
294
301
  next unless self.get_model.respond_to?(action)
295
302
 
296
303
  self.define_method(action) do
@@ -306,7 +313,7 @@ module RESTFramework::BaseModelControllerMixin
306
313
 
307
314
  # Delegate extra member actions.
308
315
  self.extra_member_actions&.each do |action, config|
309
- next unless config.is_a?(Hash) && config[:delegate]
316
+ next unless config.is_a?(Hash) && config.dig(:metadata, :delegate)
310
317
  next unless self.get_model.method_defined?(action)
311
318
 
312
319
  self.define_method(action) do
@@ -16,15 +16,14 @@ module RESTFramework::Utils
16
16
  v = v.symbolize_keys
17
17
  methods = v.delete(:methods)
18
18
 
19
- # First, remove any metadata keys.
20
- delegate = v.delete(:delegate)
21
- fields = v.delete(:fields)
19
+ # First, remove the route metadata.
20
+ metadata = v.delete(:metadata) || {}
22
21
 
23
22
  # Add label to fields.
24
- if controller && fields
25
- fields = fields.map { |f| [f, {}] }.to_h if f.is_a?(Array)
26
- fields&.each do |field, cfg|
27
- cfg[:label] = controller.get_label(field)
23
+ if controller && metadata[:fields]
24
+ metadata[:fields] = metadata[:fields].map { |f| [f, {}] }.to_h if f.is_a?(Array)
25
+ metadata[:fields]&.each do |field, cfg|
26
+ cfg[:label] = controller.get_label(field) unless cfg[:label]
28
27
  end
29
28
  end
30
29
 
@@ -47,8 +46,7 @@ module RESTFramework::Utils
47
46
  path: path,
48
47
  methods: methods,
49
48
  kwargs: kwargs,
50
- delegate: delegate,
51
- fields: fields,
49
+ metadata: metadata.presence,
52
50
  type: :extra,
53
51
  }.compact,
54
52
  ]
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.0
4
+ version: 0.8.2
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-01-22 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails