activerecord-after-transaction 0.0.3 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9555e91959102f69179f531cb9f8c0ec4f9c50a7
4
- data.tar.gz: 2c071199ff0c49892681e5605357877458b8a9c5
3
+ metadata.gz: 5ef369c0f8c5259b7119e4a2d4b60b84c5845af8
4
+ data.tar.gz: 906523a841070b30170572d556c055c3fe5d2408
5
5
  SHA512:
6
- metadata.gz: 50a8607a5e727b6b7806dd20f53dd015b35ad91c4abddd42a8a995a666be03c8944973b027c5f6d692badb3332a69c71d24f930830ca3c92e7982ce9b48a73c3
7
- data.tar.gz: cf5e96d535dafb6ff11b47aed864e53da79f55a17d46e83a2ad0be6e0905f8d314a1764dcda0ca2631be8f24dbd1df7c4066596ab79b62f75b485af14203552a
6
+ metadata.gz: 9ce037121c05a894be10534998f83ebefced301a4f15e2f43341ae27f6cb51e362786158a2246cd163cf8bf89d7ca329eb3bfcc2ba2be5b1ddd5891eff1cc6e9
7
+ data.tar.gz: f5c8a87222dc38e9c2ca682bb604793eeb7256142102190448f76fac29b8471518f736b19844908b46d700d7dfeba747b02e5eee8ab1a8ee4417ff7a00420aea
@@ -6,11 +6,14 @@ rvm:
6
6
  - 2.1
7
7
 
8
8
  env:
9
- -
10
- - ACTIVE_RECORD_VERSION=3.2.0
11
- - ACTIVE_RECORD_VERSION=4.0.0
12
- - ACTIVE_RECORD_VERSION=4.1.0
13
- - ACTIVE_RECORD_VERSION=4.2.0.beta4
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 from: :draft, to: :published do
51
- after_transaction do
52
- UserMailer.notify_publish(record).deliver
53
- end
54
- end
55
- after_transition from: :draft, to: :deleted do
56
- after_transaction do
57
- UserMailer.notify_publish(record).deliver
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.3
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.each do |block|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-after-transaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Taniwaki