active_snapshot 0.2.3 → 0.2.4

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
  SHA256:
3
- metadata.gz: 7f9f530f0b44c50f31da3e79937c51551bc03ef8fe3d730c500068d642f10df5
4
- data.tar.gz: '029ad3e165ef4bba92031c1db765335a0cee40b419ab5d4c4c1ed7b402dca595'
3
+ metadata.gz: 204744938dec9e53545cc73a6497d47b9463b76b0622491d442b5ed4169b7c83
4
+ data.tar.gz: dee647e71ff99f91e79764f6094e9253fa74b9641e6f2e611ea10485e3d1d570
5
5
  SHA512:
6
- metadata.gz: 9a502d15dda8b60c30e20a3fe6feea694e92569f6ce44eca50fd0544b14947df44499d727502345527c6456b681995673d78ebd80ac4bf6117d9868535c06275
7
- data.tar.gz: cf6014aa8d08761a4e38be0769917732610b7b1fe41925c9f5d02c36a53ad0551b7781ed85e333792b936e2c823884f38face8310bc8a6f25845e4995ac7c6e8
6
+ metadata.gz: fe9542a0beecba0f52d3d25f0dfbd1197f31eb4ab9758f7ccfaf0e5455dfd150ef6ee1ba81fc138383ff8004a9e26a037a6ad72c004766bac1f0a3bf68edb4e6
7
+ data.tar.gz: eeab5ae90f2dc09f34ece44aa51992df834cf552693849d4595554e08448d4d8fceac954cb5ccbbe47089b1a868eeb089b5391ed3cf8a410aad6d436e6a3ef6a
data/CHANGELOG.md CHANGED
@@ -2,12 +2,17 @@ CHANGELOG
2
2
  ---------
3
3
 
4
4
  - **UNRELEASED**
5
- * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.2.3...master)
5
+ * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.2.4...master)
6
6
  * Nothing yet
7
7
 
8
- - **UNRELEASED**
8
+ - **v0.2.4** - Feb 25, 2022
9
+ * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.2.3...v0.2.4)
10
+ * [PR #20](https://github.com/westonganger/active_snapshot/pull/20) - Resolve error when `has_snapshot_children` has not been defined as it should be optional
11
+ * [PR #18](https://github.com/westonganger/active_snapshot/pull/18) - Fix bug where sub-classes of a model would not be assigned correctly as parent when restoring
12
+
13
+ - **v0.2.3** - Jan 7, 2022
9
14
  * [View Diff](https://github.com/westonganger/active_snapshot/compare/v0.2.2...v0.2.3)
10
- * Support Ruby 3.1
15
+ * Support Ruby 3.1 using `YAML.unsafe_load`
11
16
  * Fix unique constraint on snapshots.identifier column
12
17
 
13
18
  - **v0.2.2** - August 27, 2021
data/README.md CHANGED
@@ -77,7 +77,7 @@ snapshot.restore!
77
77
  snapshot.destroy!
78
78
  ```
79
79
 
80
- # Restoring Associated / Child Records
80
+ # Tracking Associated / Child Records
81
81
 
82
82
  ```ruby
83
83
  class Post < ActiveRecord::Base
@@ -38,9 +38,7 @@ module ActiveSnapshot
38
38
  class_methods do
39
39
 
40
40
  def has_snapshot_children(&block)
41
- if !block_given? && !defined?(@snapshot_children_proc)
42
- raise ArgumentError.new("Invalid `has_snapshot_children` requires block to be defined")
43
- elsif block_given?
41
+ if block_given?
44
42
  @snapshot_children_proc = block
45
43
  else
46
44
  @snapshot_children_proc
@@ -98,7 +98,7 @@ module ActiveSnapshot
98
98
 
99
99
  reified_children_hash[key] << reified_item
100
100
 
101
- elsif [self.item_id, self.item_type] == [si.item_id, si.item_type]
101
+ elsif self.item_id == si.item_id && (self.item_type == si.item_type || si.item_type.constantize.new.is_a?(self.item_type.constantize))
102
102
  reified_parent = reified_item
103
103
  end
104
104
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveSnapshot
2
- VERSION = "0.2.3".freeze
2
+ VERSION = "0.2.4".freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ class ParentWithoutChildren < ApplicationRecord
2
+ include ActiveSnapshot
3
+
4
+ self.table_name = "posts"
5
+ end
@@ -0,0 +1,11 @@
1
+ class SubPost < Post
2
+ has_snapshot_children do
3
+ instance = self.class.includes(:comments, :notes).find(id)
4
+
5
+ {
6
+ comments: instance.comments,
7
+ notes: instance.notes,
8
+ nil_assoc: nil,
9
+ }
10
+ end
11
+ end
Binary file