deep_unrest 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbbfefbc56611c2e591a4a0b4765ea55b8692208
4
- data.tar.gz: eedb25cd0ab54ba479e8d54fba7170f1161708ae
3
+ metadata.gz: a6f9f64c69d2c7dd0d20bf22ed54cc65a93ae23e
4
+ data.tar.gz: 21e86160034752201ab7f58fefe798769107c67b
5
5
  SHA512:
6
- metadata.gz: 458883abb589902b4958544173915d8783d4cfd9b99a1ad13a08bb75c54f1b6e1b6a8cf5985c3f9d07ca0d01ae1a8f92f672def3f9d80874fa0d03584e26f5ee
7
- data.tar.gz: 503d64e14fc93803a813e45813a387f923b7af89a21e03dc65af0de3e488ef6d45eb4c2f451f0119541d934926d3ccf53d3f0755b2bc82eb971f170f8451bdf7
6
+ metadata.gz: 197266467e40e207025ac6ac148acbae32025f26dbca897857a0100381a45ee46756216b3ff7131d0f6e5f9c2445e585f721e5b852e22eac4c25f9c8550d0db3
7
+ data.tar.gz: 21fafc16124e69101652e6c2e957c4b51e506dfffec4a61b2abb43da48db7cd9a5e57539409840b0ff1a8bbd6fc947a587c2d82c060c118818536a6c82dccb64
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeepUnrest
4
- VERSION = '0.1.22'
4
+ VERSION = '0.1.23'
5
5
  end
data/lib/deep_unrest.rb CHANGED
@@ -342,15 +342,14 @@ module DeepUnrest
342
342
  end
343
343
 
344
344
  def self.combine_arrays(a, b)
345
- # get list of dupe items
345
+ # get list of items duped by id
346
346
  groups = (a + b).flatten.group_by { |item| item[:id] }
347
-
348
347
  dupes = groups.select { |_, v| v.size > 1 }.values
349
348
 
350
- # combine non-dupe items
349
+ # filter non-dupe
351
350
  non_dupes = groups.select { |_, v| v.size == 1 }.values
352
351
 
353
- # deep_merge dupes
352
+ # recrsively merge dupes
354
353
  merged = dupes.map do |(a2, b2)|
355
354
  a2.deep_merge(b2) do |_, a3, b3|
356
355
  if a3.is_a? Array
@@ -361,6 +360,7 @@ module DeepUnrest
361
360
  end
362
361
  end
363
362
 
363
+ # add merged dupes to non-dupes
364
364
  (non_dupes + merged).flatten
365
365
  end
366
366
 
@@ -493,7 +493,7 @@ module DeepUnrest
493
493
  '@@temp_ids'
494
494
  )
495
495
 
496
- temp_id_map[ctx] = {}
496
+ temp_id_map[ctx] ||= {}
497
497
 
498
498
  # reject new resources marked for destruction
499
499
  viable_params = params.reject do |param|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_unrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails