clone_kit 0.3.0 → 0.3.1

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: b62cef9da193908351d660a1089e8778553a963e
4
- data.tar.gz: ff375e6bce0abff22230fb94ec0be5bd3e31adc0
3
+ metadata.gz: 0b0aec7c705b57c2f5f5edc6b66569c9932b4364
4
+ data.tar.gz: 239c4c973df017ed083b8ac80d204328d5c0fd28
5
5
  SHA512:
6
- metadata.gz: 3417281d9a7f0c7d6f701f9185f187165d766263215b4faf5f8b9ca06916f29f8eadd61ae34724c83c6e75e28564aa62153d65dca0e940dafb7f3c2b6964109b
7
- data.tar.gz: 9d34d0962ce7a93b60eb5e1688be2b8e07e39d7b0aa695eb70e2a974a57b4ed4a541cdb0151bf1017dd122298933d732076b0b5be1db142419d04ac3fb6f16fa
6
+ metadata.gz: 3ca9701c9985621966beea58a720fae62622bd67774909c544d45255150212a2042dcbe9a545d4c3ddfeec329f37528741596e9cc794980b09875e027b7d9a91
7
+ data.tar.gz: 3ad4157dcc181fb178c16a4ee7c475ee12925d183a636bcae67971fbc3242817b351ad51e6b2a85a714ce5a9fb526907a6ef455f68db8e683b3ccc84700b00db
@@ -56,7 +56,7 @@ module CloneKit
56
56
  item
57
57
  end
58
58
 
59
- return nil if first_item.nil?
59
+ return empty_embedded(metadata) if first_item.nil?
60
60
 
61
61
  cloner = MongoidRulesetCloner.new(polymorphic_class(metadata.class_name, first_item))
62
62
  embedded_cloner = CloneKit::Decorators::EmbeddedClonerDecorator.new(cloner, records: Array.wrap(item))
@@ -70,6 +70,10 @@ module CloneKit
70
70
  end
71
71
  end
72
72
 
73
+ def empty_embedded(metadata)
74
+ metadata.macro == :embeds_many ? [] : nil
75
+ end
76
+
73
77
  def apply_rules_and_save(mapping, attributes)
74
78
  new_id = BSON::ObjectId.new
75
79
  old_id = attributes["_id"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloneKit
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clone_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Croft
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2017-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis