idempotent_transaction 0.1.0 → 0.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: dcd664a58b6c461af1bec8fba8282778e8a0b13214d376f3f6162d438af769a0
4
- data.tar.gz: b9b85a18ec9b858ba905924aa50b9b3634aca5801aafd6f14eca2ec1626bfd1a
3
+ metadata.gz: ce9d97fae14defc1d003ed97c3ae7a5f1a2f78e81d6ff380f7290409622fcad7
4
+ data.tar.gz: 577db0f386bd1b10dc58f37257f92bfed998722f5d15ca01c2558665185b47a3
5
5
  SHA512:
6
- metadata.gz: f16f1c13b364afdaed065a440657f6c9b989cfc0118589c3b6db94d64c8c1837a67eac0c17fde27058dd9003beb356281d8f8e8a3ca30544f0ca1b6a67b68ba5
7
- data.tar.gz: 7d8e1a8ac855c6b29c7a8a218def7d2d23d1ce3d29a1c9a4e8eb47df88aad82a156cbfdb8712fd41150bf9b0baad81df900c5d26a8b2ddbcfa7621a187d0d265
6
+ metadata.gz: 4a7f7b05b3fb196fedaa938180392865588e4298368936397af8af6d9ff959e202d71d589f4ea511d180817d84e4a2deb7ab914f9a4d26fb7e5d6948bdfe602d
7
+ data.tar.gz: 9948c2b8ac6f1d8a405afe3b380496f2fef0939e871d995f77321cedfb0042a29e5dfd0898aeb6835fa907edb2773676d38e86ad72bc53788e6c4c8e12f7f8d8
@@ -0,0 +1,2 @@
1
+ # 0.2.0
2
+ Change `#idempotent_transaction` to return block result as is. #1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 ota42y
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -130,7 +130,7 @@ end
130
130
 
131
131
  We use transaction so we rewrite this code like this.
132
132
 
133
- ```
133
+ ```ruby
134
134
  exec = IdempotentExecutor.new(user_id: user.id, type: :post_create, signature: 'abcdefg')
135
135
 
136
136
  ActiveRecord::Base.transaction do
@@ -25,16 +25,16 @@ module IdempotentTransaction
25
25
 
26
26
  def idempotent_transaction(force: false)
27
27
  self.class.transaction do
28
- yield
29
-
30
- begin
31
- save!
32
- rescue ActiveRecord::RecordNotUnique
33
- raise ActiveRecord::Rollback unless force
28
+ yield.tap do
29
+ begin
30
+ save!
31
+ rescue ActiveRecord::RecordNotUnique
32
+ raise ActiveRecord::Rollback unless force
33
+ end
34
+
35
+ @finished = true
36
+ @executed = true
34
37
  end
35
-
36
- @finished = true
37
- @executed = true
38
38
  end
39
39
  end
40
40
 
@@ -1,3 +1,3 @@
1
1
  module IdempotentTransaction
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idempotent_transaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-17 00:00:00.000000000 Z
11
+ date: 2018-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -119,8 +119,10 @@ files:
119
119
  - ".rspec"
120
120
  - ".rubocop.yml"
121
121
  - ".travis.yml"
122
+ - CHANGELOG.md
122
123
  - CODE_OF_CONDUCT.md
123
124
  - Gemfile
125
+ - LICENSE.txt
124
126
  - README.md
125
127
  - Rakefile
126
128
  - bin/console