after_commit_everywhere 1.1.0 → 1.2.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
  SHA256:
3
- metadata.gz: 4425b11aa2651bd44ec24dc839e1338537f087f89c3f19f250d3ad2aeb0fad07
4
- data.tar.gz: 143406ceecd3d9d3e1f7999f8cbb3754c19186036a7b2f47f19996c932048e26
3
+ metadata.gz: 22ac14ea80692909c9a464d9ad47d3c8d29950e020530a435e1def88763fd53f
4
+ data.tar.gz: 761b7db7496e62837332714f55b9f9f916fd5b4d515515d18bab7947cb226270
5
5
  SHA512:
6
- metadata.gz: fdaa287369af57e90b69699fdbd11b687491ea9c938af714e8a68871954b3685e07c4a9ba16939094ea6f082cec84ce351c9354341685f42bcd58bcc0307ee29
7
- data.tar.gz: 5a42c24b63cbdf2d84597e3fa6071d588a76e8821736239a146708dd155a8492dc657c29577022d7072c13ecdcc4d0b1ee22243701d1e1058ebcd13ee6072573
6
+ metadata.gz: 4d764c065a1d7fd99614e0e98c270a211a5a6fcb661068cb3edfaf34910d58b2a9754838fd6e5bf06f27e2caf6bb23209d8508153388de350250a52e26a466d9
7
+ data.tar.gz: 20e3d66fdd8ecf32ac6087fe2d5142676577445c254bf750845d430ada830f5b7b121d35a76e486cd71468b11c67ce7f42ba721bf46db7f0370c13db0d177072
@@ -18,15 +18,6 @@ jobs:
18
18
  fail-fast: false
19
19
  matrix:
20
20
  include:
21
- - ruby: '2.5'
22
- activerecord: '4.2'
23
- gemfile: 'activerecord_4_2.gemfile'
24
- - ruby: '2.6'
25
- activerecord: '5.0'
26
- gemfile: 'activerecord_5_0.gemfile'
27
- - ruby: '2.6'
28
- activerecord: '5.1'
29
- gemfile: 'activerecord_5_1.gemfile'
30
21
  - ruby: '2.6'
31
22
  activerecord: '5.2'
32
23
  gemfile: 'activerecord_5_2.gemfile'
@@ -37,6 +28,9 @@ jobs:
37
28
  activerecord: '6.1'
38
29
  gemfile: 'activerecord_6_1.gemfile'
39
30
  - ruby: '3.0'
31
+ activerecord: '7.0'
32
+ gemfile: 'activerecord_7_0.gemfile'
33
+ - ruby: '3.1'
40
34
  activerecord: 'HEAD'
41
35
  gemfile: 'activerecord_master.gemfile'
42
36
  container:
data/Appraisals CHANGED
@@ -31,6 +31,12 @@ appraise "activerecord-6-1" do
31
31
  gem "rspec-rails", "~> 4.0"
32
32
  end
33
33
 
34
+ appraise "activerecord-7-0" do
35
+ gem "activerecord", "~> 7.0.0"
36
+ gem "sqlite3", "~> 1.4"
37
+ gem "rspec-rails", "~> 5.0"
38
+ end
39
+
34
40
  appraise "activerecord-master" do
35
41
  git "https://github.com/rails/rails.git" do
36
42
  gem "rails"
@@ -38,5 +44,5 @@ appraise "activerecord-master" do
38
44
  end
39
45
 
40
46
  gem "sqlite3", "~> 1.4"
41
- gem "rspec-rails", "~> 4.0"
47
+ gem "rspec-rails", "~> 5.0"
42
48
  end
data/CHANGELOG.md CHANGED
@@ -4,7 +4,25 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
7
+ ## 1.2.0 (2022-03-26)
8
+
9
+ ### Added
10
+
11
+ - Allow to change callbacks' behavior when they are called outside transaction:
12
+
13
+ ```ruby
14
+ AfterCommitEverywhere.after_commit(without_tx: :raise) do
15
+ # Will be executed only if was called within transaction
16
+ # Error will be raised otherwise
17
+ end
18
+ ```
19
+
20
+ Available values for `without_tx` keyword argument:
21
+ - `:execute` to execute callback immediately
22
+ - `:warn_and_execute` to print warning and execute immediately
23
+ - `:raise` to raise an exception instead of executing
24
+
25
+ [Pull request #18](https://github.com/Envek/after_commit_everywhere/pull/18) by [@lolripgg][].
8
26
 
9
27
  ## 1.1.0 (2021-08-05)
10
28
 
@@ -54,3 +72,4 @@ See [#11](https://github.com/Envek/after_commit_everywhere/issues/11) for discus
54
72
  [@arjun810]: https://github.com/arjun810 "Arjun Singh"
55
73
  [@joevandyk]: https://github.com/joevandyk "Joe Van Dyk"
56
74
  [@stokarenko]: https://github.com/stokarenko "Sergey Tokarenko"
75
+ [@lolripgg]: https://github.com/lolripgg "James Brewer"
data/Gemfile.lock CHANGED
@@ -1,78 +1,84 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- after_commit_everywhere (1.0.0)
4
+ after_commit_everywhere (1.1.0)
5
5
  activerecord (>= 4.2)
6
6
  activesupport
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.1.4)
12
- actionpack (= 6.1.4)
13
- activesupport (= 6.1.4)
11
+ actioncable (7.0.2.3)
12
+ actionpack (= 7.0.2.3)
13
+ activesupport (= 7.0.2.3)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.1.4)
17
- actionpack (= 6.1.4)
18
- activejob (= 6.1.4)
19
- activerecord (= 6.1.4)
20
- activestorage (= 6.1.4)
21
- activesupport (= 6.1.4)
16
+ actionmailbox (7.0.2.3)
17
+ actionpack (= 7.0.2.3)
18
+ activejob (= 7.0.2.3)
19
+ activerecord (= 7.0.2.3)
20
+ activestorage (= 7.0.2.3)
21
+ activesupport (= 7.0.2.3)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.1.4)
24
- actionpack (= 6.1.4)
25
- actionview (= 6.1.4)
26
- activejob (= 6.1.4)
27
- activesupport (= 6.1.4)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.0.2.3)
27
+ actionpack (= 7.0.2.3)
28
+ actionview (= 7.0.2.3)
29
+ activejob (= 7.0.2.3)
30
+ activesupport (= 7.0.2.3)
28
31
  mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
29
35
  rails-dom-testing (~> 2.0)
30
- actionpack (6.1.4)
31
- actionview (= 6.1.4)
32
- activesupport (= 6.1.4)
33
- rack (~> 2.0, >= 2.0.9)
36
+ actionpack (7.0.2.3)
37
+ actionview (= 7.0.2.3)
38
+ activesupport (= 7.0.2.3)
39
+ rack (~> 2.0, >= 2.2.0)
34
40
  rack-test (>= 0.6.3)
35
41
  rails-dom-testing (~> 2.0)
36
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.1.4)
38
- actionpack (= 6.1.4)
39
- activerecord (= 6.1.4)
40
- activestorage (= 6.1.4)
41
- activesupport (= 6.1.4)
43
+ actiontext (7.0.2.3)
44
+ actionpack (= 7.0.2.3)
45
+ activerecord (= 7.0.2.3)
46
+ activestorage (= 7.0.2.3)
47
+ activesupport (= 7.0.2.3)
48
+ globalid (>= 0.6.0)
42
49
  nokogiri (>= 1.8.5)
43
- actionview (6.1.4)
44
- activesupport (= 6.1.4)
50
+ actionview (7.0.2.3)
51
+ activesupport (= 7.0.2.3)
45
52
  builder (~> 3.1)
46
53
  erubi (~> 1.4)
47
54
  rails-dom-testing (~> 2.0)
48
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- active_attr (0.15.3)
50
- actionpack (>= 3.0.2, < 7.0)
51
- activemodel (>= 3.0.2, < 7.0)
52
- activesupport (>= 3.0.2, < 7.0)
53
- activejob (6.1.4)
54
- activesupport (= 6.1.4)
56
+ active_attr (0.15.4)
57
+ actionpack (>= 3.0.2, < 7.1)
58
+ activemodel (>= 3.0.2, < 7.1)
59
+ activesupport (>= 3.0.2, < 7.1)
60
+ activejob (7.0.2.3)
61
+ activesupport (= 7.0.2.3)
55
62
  globalid (>= 0.3.6)
56
- activemodel (6.1.4)
57
- activesupport (= 6.1.4)
58
- activerecord (6.1.4)
59
- activemodel (= 6.1.4)
60
- activesupport (= 6.1.4)
61
- activestorage (6.1.4)
62
- actionpack (= 6.1.4)
63
- activejob (= 6.1.4)
64
- activerecord (= 6.1.4)
65
- activesupport (= 6.1.4)
66
- marcel (~> 1.0.0)
63
+ activemodel (7.0.2.3)
64
+ activesupport (= 7.0.2.3)
65
+ activerecord (7.0.2.3)
66
+ activemodel (= 7.0.2.3)
67
+ activesupport (= 7.0.2.3)
68
+ activestorage (7.0.2.3)
69
+ actionpack (= 7.0.2.3)
70
+ activejob (= 7.0.2.3)
71
+ activerecord (= 7.0.2.3)
72
+ activesupport (= 7.0.2.3)
73
+ marcel (~> 1.0)
67
74
  mini_mime (>= 1.1.0)
68
- activesupport (6.1.4)
75
+ activesupport (7.0.2.3)
69
76
  concurrent-ruby (~> 1.0, >= 1.0.2)
70
77
  i18n (>= 1.6, < 2)
71
78
  minitest (>= 5.1)
72
79
  tzinfo (~> 2.0)
73
- zeitwerk (~> 2.3)
74
- anyway_config (2.1.0)
75
- ruby-next-core (>= 0.11.0)
80
+ anyway_config (2.3.0)
81
+ ruby-next-core (>= 0.14.0)
76
82
  appraisal (2.4.1)
77
83
  bundler
78
84
  rake
@@ -80,83 +86,100 @@ GEM
80
86
  ast (2.4.2)
81
87
  builder (3.2.4)
82
88
  coderay (1.1.3)
83
- concurrent-ruby (1.1.9)
89
+ concurrent-ruby (1.1.10)
84
90
  crass (1.0.6)
85
- diff-lcs (1.4.4)
91
+ diff-lcs (1.5.0)
92
+ digest (3.1.0)
86
93
  erubi (1.10.0)
87
- globalid (0.5.2)
94
+ globalid (1.0.0)
88
95
  activesupport (>= 5.0)
89
- i18n (1.8.10)
96
+ i18n (1.10.0)
90
97
  concurrent-ruby (~> 1.0)
91
- isolator (0.7.0)
98
+ io-wait (0.2.1)
99
+ isolator (0.8.0)
92
100
  sniffer (>= 0.3.1)
93
101
  jaro_winkler (1.5.4)
94
- loofah (2.11.0)
102
+ loofah (2.15.0)
95
103
  crass (~> 1.0.2)
96
104
  nokogiri (>= 1.5.9)
97
105
  mail (2.7.1)
98
106
  mini_mime (>= 0.1.1)
99
- marcel (1.0.1)
107
+ marcel (1.0.2)
100
108
  method_source (1.0.0)
101
- mini_mime (1.1.0)
102
- mini_portile2 (2.6.1)
103
- minitest (5.14.4)
109
+ mini_mime (1.1.2)
110
+ mini_portile2 (2.8.0)
111
+ minitest (5.15.0)
112
+ net-imap (0.2.3)
113
+ digest
114
+ net-protocol
115
+ strscan
116
+ net-pop (0.1.1)
117
+ digest
118
+ net-protocol
119
+ timeout
120
+ net-protocol (0.1.2)
121
+ io-wait
122
+ timeout
123
+ net-smtp (0.3.1)
124
+ digest
125
+ net-protocol
126
+ timeout
104
127
  nio4r (2.5.8)
105
- nokogiri (1.12.2)
106
- mini_portile2 (~> 2.6.1)
128
+ nokogiri (1.13.3)
129
+ mini_portile2 (~> 2.8.0)
107
130
  racc (~> 1.4)
108
- parallel (1.20.1)
109
- parser (3.0.2.0)
131
+ parallel (1.22.1)
132
+ parser (3.1.1.0)
110
133
  ast (~> 2.4.1)
111
134
  pry (0.14.1)
112
135
  coderay (~> 1.1)
113
136
  method_source (~> 1.0)
114
- racc (1.5.2)
137
+ racc (1.6.0)
115
138
  rack (2.2.3)
116
139
  rack-test (1.1.0)
117
140
  rack (>= 1.0, < 3)
118
- rails (6.1.4)
119
- actioncable (= 6.1.4)
120
- actionmailbox (= 6.1.4)
121
- actionmailer (= 6.1.4)
122
- actionpack (= 6.1.4)
123
- actiontext (= 6.1.4)
124
- actionview (= 6.1.4)
125
- activejob (= 6.1.4)
126
- activemodel (= 6.1.4)
127
- activerecord (= 6.1.4)
128
- activestorage (= 6.1.4)
129
- activesupport (= 6.1.4)
141
+ rails (7.0.2.3)
142
+ actioncable (= 7.0.2.3)
143
+ actionmailbox (= 7.0.2.3)
144
+ actionmailer (= 7.0.2.3)
145
+ actionpack (= 7.0.2.3)
146
+ actiontext (= 7.0.2.3)
147
+ actionview (= 7.0.2.3)
148
+ activejob (= 7.0.2.3)
149
+ activemodel (= 7.0.2.3)
150
+ activerecord (= 7.0.2.3)
151
+ activestorage (= 7.0.2.3)
152
+ activesupport (= 7.0.2.3)
130
153
  bundler (>= 1.15.0)
131
- railties (= 6.1.4)
132
- sprockets-rails (>= 2.0.0)
154
+ railties (= 7.0.2.3)
133
155
  rails-dom-testing (2.0.3)
134
156
  activesupport (>= 4.2.0)
135
157
  nokogiri (>= 1.6)
136
- rails-html-sanitizer (1.3.0)
158
+ rails-html-sanitizer (1.4.2)
137
159
  loofah (~> 2.3)
138
- railties (6.1.4)
139
- actionpack (= 6.1.4)
140
- activesupport (= 6.1.4)
160
+ railties (7.0.2.3)
161
+ actionpack (= 7.0.2.3)
162
+ activesupport (= 7.0.2.3)
141
163
  method_source
142
- rake (>= 0.13)
164
+ rake (>= 12.2)
143
165
  thor (~> 1.0)
144
- rainbow (3.0.0)
166
+ zeitwerk (~> 2.5)
167
+ rainbow (3.1.1)
145
168
  rake (13.0.6)
146
169
  rexml (3.2.5)
147
- rspec (3.10.0)
148
- rspec-core (~> 3.10.0)
149
- rspec-expectations (~> 3.10.0)
150
- rspec-mocks (~> 3.10.0)
151
- rspec-core (3.10.1)
152
- rspec-support (~> 3.10.0)
153
- rspec-expectations (3.10.1)
170
+ rspec (3.11.0)
171
+ rspec-core (~> 3.11.0)
172
+ rspec-expectations (~> 3.11.0)
173
+ rspec-mocks (~> 3.11.0)
174
+ rspec-core (3.11.0)
175
+ rspec-support (~> 3.11.0)
176
+ rspec-expectations (3.11.0)
154
177
  diff-lcs (>= 1.2.0, < 2.0)
155
- rspec-support (~> 3.10.0)
156
- rspec-mocks (3.10.2)
178
+ rspec-support (~> 3.11.0)
179
+ rspec-mocks (3.11.0)
157
180
  diff-lcs (>= 1.2.0, < 2.0)
158
- rspec-support (~> 3.10.0)
159
- rspec-rails (5.0.1)
181
+ rspec-support (~> 3.11.0)
182
+ rspec-rails (5.1.1)
160
183
  actionpack (>= 5.2)
161
184
  activesupport (>= 5.2)
162
185
  railties (>= 5.2)
@@ -164,7 +187,7 @@ GEM
164
187
  rspec-expectations (~> 3.10)
165
188
  rspec-mocks (~> 3.10)
166
189
  rspec-support (~> 3.10)
167
- rspec-support (3.10.2)
190
+ rspec-support (3.11.0)
168
191
  rubocop (0.81.0)
169
192
  jaro_winkler (~> 1.5.1)
170
193
  parallel (~> 1.10)
@@ -173,27 +196,22 @@ GEM
173
196
  rexml
174
197
  ruby-progressbar (~> 1.7)
175
198
  unicode-display_width (>= 1.4.0, < 2.0)
176
- ruby-next-core (0.12.0)
199
+ ruby-next-core (0.15.0)
177
200
  ruby-progressbar (1.11.0)
178
201
  sniffer (0.4.0)
179
202
  active_attr (>= 0.10.2)
180
203
  anyway_config (>= 1.0)
181
- sprockets (4.0.2)
182
- concurrent-ruby (~> 1.0)
183
- rack (> 1, < 3)
184
- sprockets-rails (3.2.2)
185
- actionpack (>= 4.0)
186
- activesupport (>= 4.0)
187
- sprockets (>= 3.0.0)
188
204
  sqlite3 (1.4.2)
189
- thor (1.1.0)
205
+ strscan (3.0.1)
206
+ thor (1.2.1)
207
+ timeout (0.2.0)
190
208
  tzinfo (2.0.4)
191
209
  concurrent-ruby (~> 1.0)
192
- unicode-display_width (1.7.0)
210
+ unicode-display_width (1.8.0)
193
211
  websocket-driver (0.7.5)
194
212
  websocket-extensions (>= 0.1.0)
195
213
  websocket-extensions (0.1.5)
196
- zeitwerk (2.4.2)
214
+ zeitwerk (2.5.4)
197
215
 
198
216
  PLATFORMS
199
217
  ruby
data/README.md CHANGED
@@ -119,6 +119,15 @@ Please keep in mind ActiveRecord's [limitations for rolling back nested transact
119
119
 
120
120
  Returns `true` when called inside open transaction, `false` otherwise.
121
121
 
122
+ ### Available callback options
123
+
124
+ - `without_tx` allows to change default callback behavior if called without transaction open.
125
+
126
+ Available values:
127
+ - `:execute` to execute callback immediately
128
+ - `:warn_and_execute` to print warning and execute immediately
129
+ - `:raise` to raise an exception instead of executing
130
+
122
131
  ### FAQ
123
132
 
124
133
  #### Does it works with transactional_test or DatabaseCleaner
@@ -171,7 +180,7 @@ class Post < ActiveRecord::Base
171
180
  end
172
181
  ```
173
182
 
174
- However, if you do something in models that requires defining such ad-hoc transactional callbacks, it may indicate that your models have too many responsibilities and these methods should be extracted to separate secialized layers (service objects, etc).
183
+ However, if you do something in models that requires defining such ad-hoc transactional callbacks, it may indicate that your models have too many responsibilities and these methods should be extracted to separate specialized layers (service objects, etc).
175
184
 
176
185
  ## Development
177
186
 
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.0.0"
6
+ gem "sqlite3", "~> 1.4"
7
+ gem "rspec-rails", "~> 5.0"
8
+
9
+ gemspec path: "../"
@@ -8,6 +8,6 @@ git "https://github.com/rails/rails.git" do
8
8
  end
9
9
 
10
10
  gem "sqlite3", "~> 1.4"
11
- gem "rspec-rails", "~> 4.0"
11
+ gem "rspec-rails", "~> 5.0"
12
12
 
13
13
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AfterCommitEverywhere
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -16,34 +16,58 @@ module AfterCommitEverywhere
16
16
  delegate :after_commit, :before_commit, :after_rollback, to: AfterCommitEverywhere
17
17
  delegate :in_transaction?, to: AfterCommitEverywhere
18
18
 
19
+ # Causes {before_commit} and {after_commit} to raise an exception when
20
+ # called outside a transaction.
21
+ RAISE = :raise
22
+ # Causes {before_commit} and {after_commit} to execute the given callback
23
+ # immediately when called outside a transaction.
24
+ EXECUTE = :execute
25
+ # Causes {before_commit} and {after_commit} to log a warning before calling
26
+ # the given callback immediately when called outside a transaction.
27
+ WARN_AND_EXECUTE = :warn_and_execute
28
+
19
29
  class << self
20
30
  # Runs +callback+ after successful commit of outermost transaction for
21
31
  # database +connection+.
22
32
  #
23
- # If called outside transaction it will execute callback immediately.
24
- #
25
33
  # @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter]
34
+ # @param without_tx [Symbol] Determines the behavior of this function when
35
+ # called without an open transaction.
36
+ #
37
+ # Must be one of: {RAISE}, {EXECUTE}, or {WARN_AND_EXECUTE}.
38
+ #
26
39
  # @param callback [#call] Callback to be executed
27
40
  # @return void
28
- def after_commit(connection: ActiveRecord::Base.connection, &callback)
41
+ def after_commit(
42
+ connection: ActiveRecord::Base.connection,
43
+ without_tx: EXECUTE,
44
+ &callback
45
+ )
29
46
  register_callback(
30
47
  connection: connection,
31
48
  name: __method__,
32
49
  callback: callback,
33
- no_tx_action: :execute,
50
+ without_tx: without_tx,
34
51
  )
35
52
  end
36
53
 
37
54
  # Runs +callback+ before committing of outermost transaction for +connection+.
38
55
  #
39
- # If called outside transaction it will execute callback immediately.
40
- #
41
56
  # Available only since Ruby on Rails 5.0. See https://github.com/rails/rails/pull/18936
42
57
  #
43
58
  # @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter]
59
+ # @param without_tx [Symbol] Determines the behavior of this function when
60
+ # called without an open transaction.
61
+ #
62
+ # Must be one of: {RAISE}, {EXECUTE}, or {WARN_AND_EXECUTE}.
63
+ #
44
64
  # @param callback [#call] Callback to be executed
45
65
  # @return void
46
- def before_commit(connection: ActiveRecord::Base.connection, &callback)
66
+ def before_commit(
67
+ connection: ActiveRecord::Base.connection,
68
+ without_tx: WARN_AND_EXECUTE,
69
+ &callback
70
+ )
47
71
  if ActiveRecord::VERSION::MAJOR < 5
48
72
  raise NotImplementedError, "#{__method__} works only with Rails 5.0+"
49
73
  end
@@ -52,7 +76,7 @@ module AfterCommitEverywhere
52
76
  connection: connection,
53
77
  name: __method__,
54
78
  callback: callback,
55
- no_tx_action: :warn_and_execute,
79
+ without_tx: without_tx,
56
80
  )
57
81
  end
58
82
 
@@ -71,23 +95,25 @@ module AfterCommitEverywhere
71
95
  connection: connection,
72
96
  name: __method__,
73
97
  callback: callback,
74
- no_tx_action: :exception,
98
+ without_tx: RAISE,
75
99
  )
76
100
  end
77
101
 
78
102
  # @api private
79
- def register_callback(connection:, name:, no_tx_action:, callback:)
103
+ def register_callback(connection:, name:, without_tx:, callback:)
80
104
  raise ArgumentError, "Provide callback to #{name}" unless callback
81
105
 
82
106
  unless in_transaction?(connection)
83
- case no_tx_action
84
- when :warn_and_execute
107
+ case without_tx
108
+ when WARN_AND_EXECUTE
85
109
  warn "#{name}: No transaction open. Executing callback immediately."
86
110
  return callback.call
87
- when :execute
111
+ when EXECUTE
88
112
  return callback.call
89
- when :exception
113
+ when RAISE
90
114
  raise NotInTransaction, "#{name} is useless outside transaction"
115
+ else
116
+ raise ArgumentError, "Invalid \"without_tx\": \"#{without_tx}\""
91
117
  end
92
118
  end
93
119
  wrap = Wrap.new(connection: connection, "#{name}": callback)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after_commit_everywhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -214,6 +214,7 @@ files:
214
214
  - gemfiles/activerecord_5_2.gemfile
215
215
  - gemfiles/activerecord_6_0.gemfile
216
216
  - gemfiles/activerecord_6_1.gemfile
217
+ - gemfiles/activerecord_7_0.gemfile
217
218
  - gemfiles/activerecord_master.gemfile
218
219
  - lib/after_commit_everywhere.rb
219
220
  - lib/after_commit_everywhere/version.rb