ar_transaction_changes 1.1.2 → 1.1.3

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: 8512832019c33caf8bd9bb39796f2db6b6e8ce74
4
- data.tar.gz: 05f8382a08442778dc3a9eb3fc4d9f573c83969d
3
+ metadata.gz: 89f3ff2a1237cc1fab8f9b2bb7b338eacb83ea97
4
+ data.tar.gz: f05afe6d47540c9bfc5e7c8a80fa1277dfc03d32
5
5
  SHA512:
6
- metadata.gz: 258b699e07a4dcc3bbce95dce4991f5916569f94764eb3c66fb2627fb12e3f98520eb0663a57986cf868f37eef0703f013a9f6d4c73e9337682d67b8e29b6de3
7
- data.tar.gz: e8b2912cc3fd090905493e6d0230da91fe08251cfea9cb1edebe93ab1eaa78619d667947d81689443f6a0d56158da4db545d2583ec632b83e76b65bfeec935f3
6
+ metadata.gz: b5c64f5f5684ac7b3f06653cc6f59e855fefd51ec285fe3e8fd6f357f76201ff3d94440c272a195fcb98f5086006c672eebc743d1eff35d76abee1c6a426e4d9
7
+ data.tar.gz: d4969d2850dbee065ba0711613968cbe8f4f096d4557da97b3ae82cb688b17804b6fb702dafd64a5ef72f5d625b2f0714de9943d5a6517cb4fd699b1400fc4cf
data/.travis.yml CHANGED
@@ -9,6 +9,7 @@ gemfile:
9
9
  - Gemfile.rails42
10
10
  - Gemfile.rails50
11
11
  - Gemfile.rails51
12
+ - Gemfile.rails52
12
13
 
13
14
  matrix:
14
15
  include:
data/Gemfile.rails52 ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.2.0.beta1"
4
+
5
+ gemspec
data/README.md CHANGED
@@ -44,6 +44,19 @@ class User < ActiveRecord::Base
44
44
  end
45
45
  ```
46
46
 
47
+ ## Important Notes
48
+
49
+ `ar_transaction_changes` may have conflict with another gems who modify
50
+ `active_record#write_attribute` method, e.g. `globalize` gem
51
+
52
+ the workaround is by requiring this gem first, for example:
53
+
54
+ ```ruby
55
+ gem 'ar_transaction_changes', require: false
56
+ gem 'globalize', require: ['ar_transaction_changes', 'globalize']
57
+
58
+ ```
59
+
47
60
  ## Contributing
48
61
 
49
62
  1. Fork it
@@ -1,4 +1,5 @@
1
1
  require "ar_transaction_changes/version"
2
+ require "active_record"
2
3
 
3
4
  module ArTransactionChanges
4
5
  def _run_commit_callbacks
@@ -17,10 +18,16 @@ module ArTransactionChanges
17
18
  @transaction_changed_attributes ||= HashWithIndifferentAccess.new
18
19
  end
19
20
 
20
- def write_attribute(attr_name, value) # override
21
+ method_name = if ActiveRecord.gem_version >= Gem::Version.new("5.2.0.beta1")
22
+ "_write_attribute"
23
+ else
24
+ "write_attribute"
25
+ end
26
+
27
+ define_method(method_name) do |attr_name, value|
21
28
  attr_name = attr_name.to_s
22
- old_value = attributes[attr_name]
23
- ret = super
29
+ old_value = read_attribute(attr_name)
30
+ ret = super(attr_name, value)
24
31
  unless transaction_changed_attributes.key?(attr_name) || value == old_value
25
32
  transaction_changed_attributes[attr_name] = old_value
26
33
  end
@@ -1,3 +1,3 @@
1
1
  module ArTransactionChanges
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
  require 'pathname'
3
3
  require 'yaml'
4
- require 'active_record'
5
4
  require 'ar_transaction_changes'
6
5
  require 'minitest/autorun'
7
6
 
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.2
4
+ version: 1.1.3
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: 2017-06-12 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -72,6 +72,7 @@ files:
72
72
  - Gemfile.rails42
73
73
  - Gemfile.rails50
74
74
  - Gemfile.rails51
75
+ - Gemfile.rails52
75
76
  - LICENSE.txt
76
77
  - README.md
77
78
  - Rakefile
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  version: '0'
102
103
  requirements: []
103
104
  rubyforge_project:
104
- rubygems_version: 2.6.10
105
+ rubygems_version: 2.6.14
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: Store transaction changes for active record objects