ar_transaction_changes 1.1.5 → 1.1.6

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: b2acb53b1999dcee1b3665da06ef90afec0801aee463790207632d3618120a28
4
- data.tar.gz: edd02898b47f64d95ee7f0eb0d30859db66b75cf75b1a2a5112b42ecd808a89c
3
+ metadata.gz: 4a6cb7a7d939217a2aa0ce44c25c2f89a97ed7457be1c1836d6e7d82e2250c9a
4
+ data.tar.gz: 4d7295698fedf9d8981be7266b86f5c0ef75794ded3f0fce511b3aec151df76e
5
5
  SHA512:
6
- metadata.gz: aa7b27f1e322d10dee7d93155594b8c174c2024dbecce12d4d1b6dd5b310664aa0a1df76b09ce4dc1c9c0332b752a2af4795386b95d4867bc0bb583ac1a280a9
7
- data.tar.gz: 10a385416ff519564fff02e55df735718b50d3bf26a88788c396e6ba591b87ad0644d8290ea65ba6924ac7725a70fc46d36cb18e959923135d3307274395de93
6
+ metadata.gz: b3fbd5e913fc97722ea9181f088f9dd2b0282751ceb5cc1588a9f73c63b5f3e1df97dfad7f4aa9ee9952b3bb52bba49edafa65419ca904623475806aad5ebb92
7
+ data.tar.gz: 8bbbcf7edd439aa32bed2d1ef988a20adc49629256b779f1e6c473193c9b28c50c0d246e80b57195b37e452d81324a7ec71fd448a35f4b8f5bebe9abd4f4b7b8
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.description = %q{Solves the problem of trying to get all the changes to an object during a transaction in an after_commit callbacks.}
12
12
  gem.summary = %q{Store transaction changes for active record objects}
13
13
  gem.homepage = "https://github.com/dylanahsmith/ar_transaction_changes"
14
+ gem.license = "MIT"
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -19,9 +19,25 @@ module ArTransactionChanges
19
19
  end
20
20
 
21
21
  def _write_attribute(attr_name, value)
22
+ _store_transaction_changed_attributes(attr_name) do
23
+ super(attr_name, value)
24
+ end
25
+ end
26
+
27
+ if ActiveRecord.version >= Gem::Version.new('6.1.0.alpha')
28
+ def write_attribute(attr_name, value)
29
+ _store_transaction_changed_attributes(attr_name) do
30
+ super(attr_name, value)
31
+ end
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def _store_transaction_changed_attributes(attr_name)
22
38
  attr_name = attr_name.to_s
23
39
  old_value = read_attribute(attr_name)
24
- ret = super(attr_name, value)
40
+ ret = yield
25
41
  new_value = read_attribute(attr_name)
26
42
  unless transaction_changed_attributes.key?(attr_name) || new_value == old_value
27
43
  transaction_changed_attributes[attr_name] = old_value
@@ -1,3 +1,3 @@
1
1
  module ArTransactionChanges
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -23,6 +23,13 @@ class TransactionChangesTest < MiniTest::Unit::TestCase
23
23
  assert_equal ["Dylan", "Dillon"], @user.stored_transaction_changes["name"]
24
24
  end
25
25
 
26
+ def test_transaction_changes_for_updating_attribute
27
+ @user[:name] = "Dillon"
28
+ @user.save!
29
+
30
+ assert_equal ["Dylan", "Dillon"], @user.stored_transaction_changes["name"]
31
+ end
32
+
26
33
  def test_transaction_changes_for_double_save
27
34
  @user.transaction do
28
35
  @user.name = "Dillon"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_transaction_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Thacker-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -76,7 +76,8 @@ files:
76
76
  - test/test_helper.rb
77
77
  - test/transaction_changes_test.rb
78
78
  homepage: https://github.com/dylanahsmith/ar_transaction_changes
79
- licenses: []
79
+ licenses:
80
+ - MIT
80
81
  metadata: {}
81
82
  post_install_message:
82
83
  rdoc_options: []
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
96
  requirements: []
96
- rubygems_version: 3.0.3
97
+ rubygems_version: 3.1.2
97
98
  signing_key:
98
99
  specification_version: 4
99
100
  summary: Store transaction changes for active record objects