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 +4 -4
- data/lib/deep_unrest/version.rb +1 -1
- data/lib/deep_unrest/write.rb +6 -6
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9bebd460553ccf2d894e302580feb1912a75016069c71216f82e5de7be1a9341
         | 
| 4 | 
            +
              data.tar.gz: f2875860efc6a05e849d2c289b855b50dc7f804dc93eee447c7de668a357e8f8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f6777eadebeb6907cc3a516bfda93ac29f7845a680c077f87fa92a665691d1dcffa46ce4d5b8157ad0f2989bd64bb4cde6f6eaafe53567a09365bb0011bddafd
         | 
| 7 | 
            +
              data.tar.gz: 4aefc9e52f4e4bd2369c31a80bb3d214fc8eeec09e839aacb049d8b8dae0cdc5adc01239d6c7b587ced6be307465c4b9f3bf6fe1706a4b13ec63e84cc53ac90e
         | 
    
        data/lib/deep_unrest/version.rb
    CHANGED
    
    
    
        data/lib/deep_unrest/write.rb
    CHANGED
    
    | @@ -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  | 
| 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? | 
| 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 | 
| 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
         |