activerecord-after-transaction 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -5
- data/README.md +11 -8
- data/VERSION +1 -1
- data/lib/activerecord-after-transaction/methods.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ef369c0f8c5259b7119e4a2d4b60b84c5845af8
|
4
|
+
data.tar.gz: 906523a841070b30170572d556c055c3fe5d2408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce037121c05a894be10534998f83ebefced301a4f15e2f43341ae27f6cb51e362786158a2246cd163cf8bf89d7ca329eb3bfcc2ba2be5b1ddd5891eff1cc6e9
|
7
|
+
data.tar.gz: f5c8a87222dc38e9c2ca682bb604793eeb7256142102190448f76fac29b8471518f736b19844908b46d700d7dfeba747b02e5eee8ab1a8ee4417ff7a00420aea
|
data/.travis.yml
CHANGED
@@ -6,11 +6,14 @@ rvm:
|
|
6
6
|
- 2.1
|
7
7
|
|
8
8
|
env:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
global:
|
10
|
+
- CODECLIMATE_REPO_TOKEN=c7c5309497d209a35d1001b3a258ce42b228abf2b55f874dc79b4b104435f60a
|
11
|
+
matrix:
|
12
|
+
-
|
13
|
+
- ACTIVE_RECORD_VERSION=3.2.0
|
14
|
+
- ACTIVE_RECORD_VERSION=4.0.0
|
15
|
+
- ACTIVE_RECORD_VERSION=4.1.0
|
16
|
+
- ACTIVE_RECORD_VERSION=4.2.0.beta4
|
14
17
|
|
15
18
|
script: "bundle exec rake spec"
|
16
19
|
|
data/README.md
CHANGED
@@ -45,16 +45,19 @@ And run `bundle install`.
|
|
45
45
|
|
46
46
|
## Usage
|
47
47
|
|
48
|
+
Just enslose what you want to execute with `after_transaction`.
|
49
|
+
|
48
50
|
```ruby
|
49
51
|
class Foo < ActiveRecord::Base
|
50
|
-
after_transition
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
def after_transition(record, transition)
|
53
|
+
if transition.to == :published
|
54
|
+
after_transaction do
|
55
|
+
UserMailer.notify_publish(record).deliver
|
56
|
+
end
|
57
|
+
elsif transition.to == :deleted
|
58
|
+
after_transaction do
|
59
|
+
UserMailer.notify_delete(record).deliver
|
60
|
+
end
|
58
61
|
end
|
59
62
|
end
|
60
63
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -18,11 +18,12 @@ module ActiveRecord::AfterTransaction
|
|
18
18
|
|
19
19
|
def execute_after_transaction
|
20
20
|
logger && logger.debug("Execute the queue")
|
21
|
-
@after_transaction_queue.
|
21
|
+
queue = @after_transaction_queue.dup
|
22
|
+
clear_after_transaction
|
23
|
+
queue.each do |block|
|
22
24
|
logger && logger.debug("Execute #{block}")
|
23
25
|
block.call
|
24
26
|
end
|
25
|
-
clear_after_transaction
|
26
27
|
end
|
27
28
|
|
28
29
|
def clear_after_transaction
|