mongoid-archivable 1.6.0 → 1.7.0

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
  SHA1:
3
- metadata.gz: 39ea08e10786da69fd02888d73ff5311550115d4
4
- data.tar.gz: 763442ac4b4451e46119ff3574a6c64d52cf96bd
3
+ metadata.gz: 921a26dc194f7addd2eaff0e4f094f86962a44e5
4
+ data.tar.gz: 66c9c7d076d1488661ea55ea7e1c60d97713f7bf
5
5
  SHA512:
6
- metadata.gz: e42df539cbf0d48e580c7e4fd10226cdb66f14bb6e799118e00581c2f06699c83bc254a17c23987b970a188b970243f9aaed169fc3189859a6e0703b208fe8a9
7
- data.tar.gz: 531755776b89e8dbbbd7363d11bfc9304fc23d66ef9f473523c807f683e0c7ae465af0140131c6dbe670234ae5a56781c1cf0913ffcfad3ac18adab7baa45c15
6
+ metadata.gz: cee5339dcbbc3861ab1c9335009d95dd82cfeec196a2c439b8fb071895383f301b7376e1556b988ae54ce9414d07d53da7591ebfc70319330cba280d5efed994
7
+ data.tar.gz: 92e3a9d9687e44c1bc8ef5b9ad02fe7bfb44286f6ce3a8c13604ebfc6df269cf9d4f39ae88e90b41d2ea89c72bb13ae8d0acdc6ac8a2773b0cf3cf1639c5bb45
@@ -1,3 +1,13 @@
1
+ # 1.7.0
2
+
3
+ * `restore` returns nil if save unsuccessful, [#14](https://github.com/Sign2Pay/mongoid-archivable/pull/14)
4
+ * added `restore!` method, [#14](https://github.com/Sign2Pay/mongoid-archivable/pull/14)
5
+ * updated `ProcessLocalizedFields` to correctly restore embedded polymorphic relations, [#13](https://github.com/Sign2Pay/mongoid-archivable/pull/13)
6
+
7
+ # 1.6.0
8
+
9
+ * Support different database or client for archived documents, [#12](https://github.com/Sign2Pay/mongoid-archivable/pull/12), thanks to [@jackbit](https://github.com/jackbit)
10
+
1
11
  # 1.5.2
2
12
 
3
13
  * correctly restore localized fields on self and embedded documents
@@ -17,15 +17,16 @@ module Mongoid
17
17
 
18
18
  embedded_relations.each do |relation|
19
19
  relation_name = relation.name.to_s
20
- relation_class = relation.class_name.constantize
21
20
 
22
21
  # convert embeds_many
23
22
  if attrs[relation_name].is_a?(Array)
24
23
  attrs[relation_name] = attrs[relation_name].map do |att|
24
+ relation_class = att.fetch('_type', relation.class_name).constantize
25
25
  ProcessLocalizedFields.call(relation_class, att)
26
26
  end
27
27
  # convert embeds_one
28
28
  elsif att = attrs[relation_name]
29
+ relation_class = att.fetch('_type', relation.class_name).constantize
29
30
  attrs[relation_name] = ProcessLocalizedFields.call(relation_class, att)
30
31
  end
31
32
  end
@@ -3,7 +3,13 @@ module Mongoid
3
3
  module Restoration
4
4
  # Restores the archived document to its former glory.
5
5
  def restore
6
- original_document.save
6
+ if original_document.save
7
+ original_document
8
+ end
9
+ end
10
+
11
+ def restore!
12
+ original_document.save!
7
13
  original_document
8
14
  end
9
15
 
@@ -35,4 +41,4 @@ module Mongoid
35
41
  end
36
42
  end
37
43
  end
38
- end
44
+ end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Archivable
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-archivable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joost Baaij
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid