ar_transaction_changes 0.0.4 → 1.0.0

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: e81a329fd3cebf47884e144eb617d4383464e9ed
4
- data.tar.gz: f44c13f9cfe8270f18c16aec9dee68e2814bac0e
3
+ metadata.gz: a8ff2de126ba16e92f20b0104ecb175c2fcf81e0
4
+ data.tar.gz: 5793e455b6b8f70bdf58e491b4e949148987ad38
5
5
  SHA512:
6
- metadata.gz: 00b1b8405525c0f5359efb2c81c1d62c094e8e034bbf27430c6000b37db3df501fc888ac527b6baaa5b472f7a18939c51c8d46cbb361c70e3c88aa3a9b2080fa
7
- data.tar.gz: dd19380b41cc98136a48980d6d2a53548cf1d71541bd774469f32943bdd842b8f81744afc591916c81547b128dce4a58413a36207060b0256528cc529b0df894
6
+ metadata.gz: a65be870f0ee580c88027537aafc1e1e6d186596096bde3f5a98c6c6c0a418c1c1912279a76e7de6ee8fa5cd1f9d5f3675f63cd00fb7fed8f3d470076aa471df
7
+ data.tar.gz: 67024564a43fb3c48d005f9e58a0a9029807aab97a36b7c4103cf63b8c32707065ddc99a31556c64d7cf0759891b00de365f84bdb0cb874f2affaeca2920daab
@@ -1,39 +1,16 @@
1
1
  require "ar_transaction_changes/version"
2
2
 
3
3
  module ArTransactionChanges
4
- # rails 4.0.0: renamed create/update to create_record/update_record
5
- # rails 4.0.6/4.1.2: prefixed create_record/update_record with an underscore
6
- create_or_update_method_format = ["_%s_record", "%s_record", "%s"].detect do |format|
7
- ["create", "update"].all? do |action|
8
- method_name = format % action
9
- ActiveRecord::Persistence.private_method_defined?(method_name.to_sym)
4
+ def run_callbacks(kind, &block)
5
+ ret = super
6
+ case kind.to_sym
7
+ when :create, :update
8
+ store_transaction_changed_attributes if ret != false
9
+ when :commit, :rollback
10
+ @transaction_changed_attributes = nil
10
11
  end
11
- end or raise "Failed to find create/update record methods to monkey patch"
12
- create_method_name = (create_or_update_method_format % "create").to_sym
13
- update_method_name = (create_or_update_method_format % "update").to_sym
14
12
 
15
- define_method(create_method_name) do |*args|
16
- super(*args).tap do |status|
17
- store_transaction_changed_attributes if status != false
18
- end
19
- end
20
-
21
- define_method(update_method_name) do |*args|
22
- super(*args).tap do |status|
23
- store_transaction_changed_attributes if status != false
24
- end
25
- end
26
-
27
- def committed!(*)
28
- super
29
- ensure
30
- @transaction_changed_attributes = nil
31
- end
32
-
33
- def rolledback!(*)
34
- super
35
- ensure
36
- @transaction_changed_attributes = nil
13
+ ret
37
14
  end
38
15
 
39
16
  def transaction_changed_attributes
@@ -1,3 +1,3 @@
1
1
  module ArTransactionChanges
2
- VERSION = "0.0.4"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_transaction_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Thacker-Smith