after_commit_changes 1.0.0 → 1.0.1
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/CHANGELOG.md +7 -0
- data/README.md +0 -1
- data/VERSION +1 -1
- data/after_commit_changes.gemspec +1 -1
- data/lib/after_commit_changes.rb +13 -4
- metadata +4 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05d161dfd3945b94e6fb19633fd6642e7d0198e4b4df776fc069145f5830bb79
|
|
4
|
+
data.tar.gz: ac61c36d5f91357f4f1ee5fde7d095af3b2d06a171bfe6cbc1e2c820a679da00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3a04e388b718d74fdaa5aac1af65186d325498dfc59a3c454427a793656fafcdddda0a5e26d941acadb1308350f90f7225da14e7579ba06dfd80ef3f5b95a1b
|
|
7
|
+
data.tar.gz: 4c32507ae1d63e28c22c2ed78bd293f21b094fb2ab2aaf89b90ab2e0f57f77e9b9474cf467fbe8119d370e0a2496c044b792fd5824e75224f01b6aebb997d85a
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 1.0.1
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Changes from rolled back transactions are no longer included in the aggregated saved changes on a subsequent save.
|
|
11
|
+
- Changes rolled back to a savepoint (i.e. a nested transaction with `requires_new: true`) are no longer included in the aggregated saved changes when the outer transaction commits.
|
|
12
|
+
- Internal state tracking saved changes is now cleared after every transaction instead of being retained on the instance after transactions with a single save.
|
|
13
|
+
|
|
7
14
|
## 1.0.0
|
|
8
15
|
|
|
9
16
|
### Added
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# AfterCommitChanges
|
|
2
2
|
|
|
3
3
|
[](https://github.com/bdurand/after_commit_changes/actions/workflows/continuous_integration.yml)
|
|
4
|
-
[](https://github.com/bdurand/after_commit_changes/actions/workflows/regression_test.yml)
|
|
5
4
|
[](https://github.com/testdouble/standard)
|
|
6
5
|
[](https://badge.fury.io/rb/after_commit_changes)
|
|
7
6
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.1
|
data/lib/after_commit_changes.rb
CHANGED
|
@@ -10,19 +10,29 @@ module AfterCommitChanges
|
|
|
10
10
|
|
|
11
11
|
base.after_save do
|
|
12
12
|
@after_commit_saved_changes ||= []
|
|
13
|
-
@after_commit_saved_changes << saved_changes
|
|
13
|
+
@after_commit_saved_changes << [self.class.connection.open_transactions, saved_changes]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
base.after_rollback do
|
|
17
|
+
if @after_commit_saved_changes
|
|
18
|
+
depth = self.class.connection.open_transactions
|
|
19
|
+
@after_commit_saved_changes.reject! { |entry_depth, _changes| entry_depth > depth }
|
|
20
|
+
@after_commit_saved_changes = nil if @after_commit_saved_changes.empty?
|
|
21
|
+
end
|
|
14
22
|
end
|
|
15
23
|
end
|
|
16
24
|
|
|
17
25
|
private
|
|
18
26
|
|
|
19
27
|
def rollup_mutations_for_transaction!
|
|
20
|
-
|
|
28
|
+
saved_changes_list = @after_commit_saved_changes
|
|
29
|
+
@after_commit_saved_changes = nil
|
|
30
|
+
return unless saved_changes_list && saved_changes_list.size > 1
|
|
21
31
|
|
|
22
32
|
attributes = @_start_transaction_state[:attributes].deep_dup
|
|
23
33
|
mutations = ActiveModel::AttributeMutationTracker.new(attributes)
|
|
24
34
|
|
|
25
|
-
|
|
35
|
+
saved_changes_list.each do |_depth, changes|
|
|
26
36
|
changes.each do |attr_name, value_change|
|
|
27
37
|
attribute = attributes[attr_name]
|
|
28
38
|
last_value = value_change.last
|
|
@@ -32,7 +42,6 @@ module AfterCommitChanges
|
|
|
32
42
|
end
|
|
33
43
|
end
|
|
34
44
|
|
|
35
|
-
@after_commit_saved_changes = nil
|
|
36
45
|
@mutations_before_last_save = mutations
|
|
37
46
|
end
|
|
38
47
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: after_commit_changes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -38,7 +37,6 @@ dependencies:
|
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
|
-
description:
|
|
42
40
|
email:
|
|
43
41
|
- bbdurand@gmail.com
|
|
44
42
|
executables: []
|
|
@@ -55,7 +53,6 @@ homepage: https://github.com/bdurand/after_commit_changes
|
|
|
55
53
|
licenses:
|
|
56
54
|
- MIT
|
|
57
55
|
metadata: {}
|
|
58
|
-
post_install_message:
|
|
59
56
|
rdoc_options: []
|
|
60
57
|
require_paths:
|
|
61
58
|
- lib
|
|
@@ -63,15 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
63
60
|
requirements:
|
|
64
61
|
- - ">="
|
|
65
62
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '2.
|
|
63
|
+
version: '2.6'
|
|
67
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
65
|
requirements:
|
|
69
66
|
- - ">="
|
|
70
67
|
- !ruby/object:Gem::Version
|
|
71
68
|
version: '0'
|
|
72
69
|
requirements: []
|
|
73
|
-
rubygems_version:
|
|
74
|
-
signing_key:
|
|
70
|
+
rubygems_version: 4.0.3
|
|
75
71
|
specification_version: 4
|
|
76
72
|
summary: Aggregate all changes made to an ActiveRecord model inside a transaction
|
|
77
73
|
into a single set of changes.
|