deep_unrest 0.1.40 → 0.1.41

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: fc8d9d60f84a4ad9dbeeee14a1d321a9074f0b55f00ba23762eb0f2a01824f5d
4
- data.tar.gz: 98201fa290e5c0846720480f03576555a1d7133ef118badada11d29d9922ade6
3
+ metadata.gz: 9bebd460553ccf2d894e302580feb1912a75016069c71216f82e5de7be1a9341
4
+ data.tar.gz: f2875860efc6a05e849d2c289b855b50dc7f804dc93eee447c7de668a357e8f8
5
5
  SHA512:
6
- metadata.gz: a1d6a1b49edaf16f77becae1f34fff757121f3b51410a63b07161c3e9a93b29942838f9196ccffaf7499bd836c61097ca60789fdaa3f2a1d3c4744fbbeb37903
7
- data.tar.gz: 67208a51ba5ecfed27c8e1a14bc64b61c479f9ef9a970c312449855eab737a1d6287c9397854d43ebb8c350557606d36c5de8d98309056ec7d345ee2bf434766
6
+ metadata.gz: f6777eadebeb6907cc3a516bfda93ac29f7845a680c077f87fa92a665691d1dcffa46ce4d5b8157ad0f2989bd64bb4cde6f6eaafe53567a09365bb0011bddafd
7
+ data.tar.gz: 4aefc9e52f4e4bd2369c31a80bb3d214fc8eeec09e839aacb049d8b8dae0cdc5adc01239d6c7b587ced6be307465c4b9f3bf6fe1706a4b13ec63e84cc53ac90e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeepUnrest
4
- VERSION = '0.1.40'
4
+ VERSION = '0.1.41'
5
5
  end
@@ -12,9 +12,8 @@ module DeepUnrest
12
12
 
13
13
  def self.create_write_mapping(k, v, addr, idx = nil)
14
14
  path = k
15
- path += '[]' if idx
16
15
  resource_addr = [*addr, path]
17
- resource_addr << idx if idx
16
+ resource_addr += ['data[]', idx] if idx
18
17
  uuid = SecureRandom.uuid
19
18
  v[:uuid] = uuid
20
19
  [{ klass: k.singularize.classify.constantize,
@@ -29,7 +28,7 @@ module DeepUnrest
29
28
  end
30
29
 
31
30
  def self.create_mapping_sequence(k, v, addr)
32
- v.each_with_index.map do |item, idx|
31
+ v[:data].each_with_index.map do |item, idx|
33
32
  create_write_mapping(k, item, addr, idx)
34
33
  end
35
34
  end
@@ -38,7 +37,7 @@ module DeepUnrest
38
37
  return unless params
39
38
 
40
39
  params.map do |k, v|
41
- if v.is_a? Array
40
+ if v[:data] && v[:data].is_a?(Array)
42
41
  create_mapping_sequence(k, v, addr)
43
42
  else
44
43
  create_write_mapping(k, v, addr)
@@ -55,7 +54,8 @@ module DeepUnrest
55
54
  item[:ar_addr] << segment if item[:ar_addr].empty?
56
55
  next unless segment == :include
57
56
 
58
- next_segment = "#{addr.shift.gsub('[]', '')}_attributes"
57
+ next_segment = "#{addr.shift}_attributes"
58
+ addr.shift if addr[0].to_s == 'data[]'
59
59
  idx = addr.shift if addr[0].is_a? Integer
60
60
  next_segment += '[]' if idx
61
61
  item[:ar_addr] << next_segment
@@ -202,7 +202,7 @@ module DeepUnrest
202
202
  def self.format_ar_error_path(base, ar_path)
203
203
  path_arr = ar_path.gsub(/\.(?!\w+$)/, '.included.')
204
204
  .gsub(/\.(?=\w+$)/, '.attributes.\1')
205
- .gsub(/\[(\d+)\]/, '[].\1')
205
+ .gsub(/\[(\d+)\]/, '.data[].\1')
206
206
  .split('.')
207
207
 
208
208
  if path_arr.size == 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_unrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.40
4
+ version: 0.1.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley