activerecord-transactionable 2.0.4 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +26 -0
- data/LICENSE +18 -4
- data/README.md +132 -36
- data/SECURITY.md +14 -0
- data/lib/activerecord/transactionable/result.rb +13 -10
- data/lib/activerecord/transactionable/version.rb +3 -1
- data/lib/activerecord/transactionable.rb +67 -55
- metadata +185 -46
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.rubocop.yml +0 -4
- data/.travis.yml +0 -50
- data/Appraisals +0 -34
- data/Gemfile +0 -18
- data/Rakefile +0 -6
- data/activerecord-transactionable.gemspec +0 -32
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/gemfiles/rails_4_0.gemfile +0 -9
- data/gemfiles/rails_4_1.gemfile +0 -9
- data/gemfiles/rails_4_2.gemfile +0 -9
- data/gemfiles/rails_5_0.gemfile +0 -9
- data/gemfiles/rails_5_1.gemfile +0 -9
- data/gemfiles/rails_5_2.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50e2e6fb7f7b4fa84e937daa693efc620451ec3ccb1fc7d1cb5154a6224087c
|
4
|
+
data.tar.gz: 2ba7e8f077edd0475721483d252be6233294a78e9c900daff2d6b810c7aba436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a2b79d3ec10a2a52be1282d7bfa7ecfa7b499146582fdc3568e6bca06cb4f2e09c4c53eeea54a8d9652e80aa249b44f3d41c7d4f5a2c77dc534a4af30cdfa4
|
7
|
+
data.tar.gz: 769582a2c37bc84cd0ac1a95b119d3fe9c17d506c76b0cd03423db03c4e8516f277fefae58e6c7fb419f54aa269b3ceb02beaf4a0a879113961f24cf81c0b986
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## Contributing
|
2
|
+
|
3
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/pboling/activerecord-transactionable][source]. This project is
|
4
|
+
intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
5
|
+
the [code of conduct][conduct].
|
6
|
+
|
7
|
+
To submit a patch, please fork the project and create a patch with
|
8
|
+
tests. Once you're happy with it send a pull request!
|
9
|
+
|
10
|
+
## Contributors
|
11
|
+
|
12
|
+
[![Contributors](https://contrib.rocks/image?repo=pboling/activerecord-transactionable)][contributors]
|
13
|
+
|
14
|
+
Made with [contributors-img][contrib-rocks].
|
15
|
+
|
16
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING)
|
17
|
+
|
18
|
+
[conduct]: https://github.com/pboling/activerecord-transactionable/blob/master/CODE_OF_CONDUCT.md
|
19
|
+
|
20
|
+
[contrib-rocks]: https://contrib.rocks
|
21
|
+
|
22
|
+
[contributors]: https://github.com/pboling/activerecord-transactionable/graphs/contributors
|
23
|
+
|
24
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
|
25
|
+
|
26
|
+
[source]: https://github.com/pboling/activerecord-transactionable/
|
data/LICENSE
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2016 - 2018, 2021 Peter H. Boling
|
4
4
|
|
5
|
-
|
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:
|
6
11
|
|
7
|
-
|
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
@@ -2,23 +2,15 @@
|
|
2
2
|
|
3
3
|
Provides a method, `transaction_wrapper` at the class and instance levels that can be used instead of `ActiveRecord#transaction`. Enables you to do transactions properly, with custom rescues and retry, including with or without locking.
|
4
4
|
|
5
|
-
| Project
|
6
|
-
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
| code quality | [![Maintainability](https://api.codeclimate.com/v1/badges/41fa99881cfe6d45e7e5/maintainability)](https://codeclimate.com/github/pboling/activerecord-transactionable/maintainability) |
|
15
|
-
| code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/activerecord-transactionable/badges/users.svg)](https://www.codetriage.com/pboling/activerecord-transactionable) |
|
16
|
-
| inline documenation | [![Inline docs](http://inch-ci.org/github/pboling/activerecord-transactionable.png)](http://inch-ci.org/github/pboling/activerecord-transactionable) |
|
17
|
-
| homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
|
18
|
-
| documentation | [on RDoc.info][documentation] |
|
19
|
-
| live chat | [![Join the chat at https://gitter.im/pboling/activerecord-transactionable](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pboling/activerecord-transactionable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
|
20
|
-
| expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
21
|
-
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌍 🌎 🌏](https://about.me/peter.boling), [🍚](https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling), [➕](https://plus.google.com/+PeterBoling/posts), [👼](https://angel.co/peter-boling), [🐛](https://www.topcoder.com/members/pboling/), [:shipit:](http://coderwall.com/pboling), [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)](http://twitter.com/galtzo) |
|
5
|
+
| Project | Activerecord::Transactionable |
|
6
|
+
|--------------------------- |--------------------------- |
|
7
|
+
| name, license, docs | [`activerecord-transactionable`][rubygems] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref] [![RubyDoc.info](https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat)][documentation] |
|
8
|
+
| version & downloads | [![Version](https://img.shields.io/gem/v/activerecord-transactionable.svg)][rubygems] [![Total Downloads](https://img.shields.io/gem/dt/activerecord-transactionable.svg)][rubygems] [![Downloads Today](https://img.shields.io/gem/rd/activerecord-transactionable.svg)][rubygems] [![Homepage](https://img.shields.io/badge/source-github-brightgreen.svg?style=flat)][source] |
|
9
|
+
| dependencies & linting | [![Depfu](https://badges.depfu.com/badges/d570491bac0ad3b0b65deb3c82028327/count.svg)][depfu] [![lint status](https://github.com/pboling/activerecord-transactionable/actions/workflows/style.yml/badge.svg)][actions] |
|
10
|
+
| unit tests | [![supported rubies](https://github.com/pboling/activerecord-transactionable/actions/workflows/supported.yml/badge.svg)][actions] [![unsupported status](https://github.com/pboling/activerecord-transactionable/actions/workflows/unsupported.yml/badge.svg)][actions] |
|
11
|
+
| coverage & maintainability | [![Test Coverage](https://api.codeclimate.com/v1/badges/41fa99881cfe6d45e7e5/test_coverage)][climate_coverage] [![codecov](https://codecov.io/gh/pboling/activerecord-transactionable/branch/master/graph/badge.svg?token=4ZNAWNxrf9)][codecov_coverage] [![Maintainability](https://api.codeclimate.com/v1/badges/41fa99881cfe6d45e7e5/maintainability)][climate_maintainability] [![Security Policy](https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat)][security] |
|
12
|
+
| resources | [![Discussion](https://img.shields.io/badge/discussions-github-brightgreen.svg?style=flat)][gh_discussions] [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) [![Join the chat at https://gitter.im/pboling/activerecord-transactionable](https://badges.gitter.im/Join%20Chat.svg)][chat] [![Blog](https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat)][blogpage] |
|
13
|
+
| Spread ~♡ⓛⓞⓥⓔ♡~ | [![Open Source Helpers](https://www.codetriage.com/pboling/activerecord-transactionable/badges/users.svg)][code_triage] [![Liberapay Patrons](https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay)][liberapay_donate] [![Sponsor Me](https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github)][gh_sponsors] [🌏][aboutme] [👼][angelme] [💻][coderme] [🌹][politicme] [![Tweet @ Peter][followme-img]][tweetme] |
|
22
14
|
|
23
15
|
Useful as an example of correct behavior for wrapping transactions.
|
24
16
|
|
@@ -27,13 +19,15 @@ NOTE: Rails' transactions are per-database connection, not per-model, nor per-in
|
|
27
19
|
|
28
20
|
## Upgrading to Version 2
|
29
21
|
|
30
|
-
In version 1 the `transaction_wrapper` returned `true` or `false`. In version 2 it returns an instance of `Activerecord::Transactionable::Result`, which has a `value`, and
|
22
|
+
In version 1 the `transaction_wrapper` returned `true` or `false`. In version 2 it returns an instance of `Activerecord::Transactionable::Result`, which has a `value`, and three methods:
|
31
23
|
```ruby
|
32
|
-
|
24
|
+
args = {}
|
25
|
+
result = transaction_wrapper(**args) do
|
33
26
|
something
|
34
27
|
end
|
35
28
|
result.fail?
|
36
29
|
result.success?
|
30
|
+
result.to_h # => a hash with diagnostic information, particularly useful when things go wrong
|
37
31
|
```
|
38
32
|
Where you used to have:
|
39
33
|
```ruby
|
@@ -53,7 +47,7 @@ end
|
|
53
47
|
Add this line to your application's Gemfile:
|
54
48
|
|
55
49
|
```ruby
|
56
|
-
gem
|
50
|
+
gem "activerecord-transactionable"
|
57
51
|
```
|
58
52
|
|
59
53
|
And then execute:
|
@@ -64,6 +58,19 @@ Or install it yourself as:
|
|
64
58
|
|
65
59
|
$ gem install activerecord-transactionable
|
66
60
|
|
61
|
+
## Compatibility
|
62
|
+
|
63
|
+
Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.6, 2.7, and
|
64
|
+
3.0. Ruby is limited to 2.5+ in the gemspec, and when it changes there will be a major release.
|
65
|
+
The `master` branch currently targets 3.0.x releases.
|
66
|
+
|
67
|
+
| Ruby OAuth Version | Maintenance Branch | Officially Supported Rubies | Unofficially Supported Rubies |
|
68
|
+
|--------------------- | ------------------ | ------------------------------------------- | ----------------------------- |
|
69
|
+
| 3.0.x | `master` | 2.6, 2.7, 3.0 | 2.5 |
|
70
|
+
| 2.0.x | `v2-maintenance` | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0 | |
|
71
|
+
|
72
|
+
NOTE: 2.0.5 is anticipated as last release of the 2.x series.
|
73
|
+
|
67
74
|
## Usage
|
68
75
|
|
69
76
|
```ruby
|
@@ -118,7 +125,7 @@ If you need to know if the transaction succeeded:
|
|
118
125
|
car = Car.new(name: nil)
|
119
126
|
result = car.transaction_wrapper(lock: true) do # uses ActiveRecord's with_lock
|
120
127
|
car.save!
|
121
|
-
|
128
|
+
end
|
122
129
|
result # => an instance of Activerecord::Transactionable::Result
|
123
130
|
result.success? # => true or false
|
124
131
|
```
|
@@ -127,10 +134,10 @@ result.success? # => true or false
|
|
127
134
|
|
128
135
|
```ruby
|
129
136
|
@client = Client.find(params[:id])
|
130
|
-
transaction_result =
|
137
|
+
transaction_result = @client.transaction_wrapper(lock: true) do
|
131
138
|
@client.assign_attributes(client_params)
|
132
139
|
@client.save!
|
133
|
-
|
140
|
+
end
|
134
141
|
if transaction_result.success?
|
135
142
|
render :show, locals: { client: @client }, status: :ok
|
136
143
|
else
|
@@ -183,8 +190,8 @@ module SendToRaygun
|
|
183
190
|
begin
|
184
191
|
Raygun.track_exception(args[:error])
|
185
192
|
Rails.logger.debug("Sent Error to Raygun: #{args[:error].class}: #{args[:error].message}")
|
186
|
-
rescue => e
|
187
|
-
Rails.logger.
|
193
|
+
rescue StandardError => e
|
194
|
+
Rails.logger.error("Sending Error #{args[:error].class}: #{args[:error].message} to Raygun Failed with: #{e.class}: #{e.message}")
|
188
195
|
end
|
189
196
|
end
|
190
197
|
end
|
@@ -195,6 +202,17 @@ Activerecord::Transactionable::ClassMethods.class_eval do
|
|
195
202
|
end
|
196
203
|
```
|
197
204
|
|
205
|
+
## More Information
|
206
|
+
|
207
|
+
* RubyDoc Documentation: [![RubyDoc.info](https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat)][documentation]
|
208
|
+
* GitHub Discussions: [![Discussion](https://img.shields.io/badge/discussions-github-brightgreen.svg?style=flat)][gh_discussions]
|
209
|
+
* Live Chat on Gitter: [![Join the chat at https://gitter.im/pboling/activerecord-transactionable](https://badges.gitter.im/Join%20Chat.svg)][chat]
|
210
|
+
* Maintainer's Blog: [![Blog](https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat)][blogpage]
|
211
|
+
|
212
|
+
## Code of Conduct
|
213
|
+
|
214
|
+
Everyone interacting with this project's code, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/activerecord-transactionable/blob/master/CODE_OF_CONDUCT.md).
|
215
|
+
|
198
216
|
## Development
|
199
217
|
|
200
218
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -203,11 +221,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
203
221
|
|
204
222
|
## Contributing
|
205
223
|
|
206
|
-
|
224
|
+
See [CONTRIBUTING.md][contributing]
|
207
225
|
|
208
|
-
##
|
226
|
+
## Contributors
|
227
|
+
|
228
|
+
[![Contributors](https://contrib.rocks/image?repo=pboling/activerecord-transactionable)][contributors]
|
209
229
|
|
210
|
-
|
230
|
+
Made with [contributors-img](https://contrib.rocks).
|
211
231
|
|
212
232
|
## Versioning
|
213
233
|
|
@@ -224,24 +244,100 @@ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two
|
|
224
244
|
For example:
|
225
245
|
|
226
246
|
```ruby
|
227
|
-
spec.add_dependency
|
247
|
+
spec.add_dependency "activerecord-transactionable", "~> 2.0"
|
228
248
|
```
|
249
|
+
## Contact
|
229
250
|
|
230
|
-
|
251
|
+
Author and maintainer is Peter Boling ([@pboling][gh_sponsors]).
|
231
252
|
|
232
|
-
|
253
|
+
Comments are welcome in the [GitHub Discussions][gh_discussions] board.
|
254
|
+
|
255
|
+
For security-related issues see [SECURITY][security].
|
233
256
|
|
234
257
|
## License
|
235
258
|
|
236
|
-
|
259
|
+
The gem is available as open source under the terms of
|
260
|
+
the [MIT License][license] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref].
|
261
|
+
See [LICENSE][license] for the official [Copyright Notice][copyright-notice-explainer].
|
262
|
+
|
263
|
+
* Copyright (c) 2016 - 2018, 2021 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
|
264
|
+
|
265
|
+
[copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
266
|
+
|
267
|
+
[license]: https://github.com/pboling/activerecord-transactionable/blob/master/LICENSE
|
237
268
|
|
238
|
-
[
|
269
|
+
[conduct]: https://github.com/pboling/activerecord-transactionable/blob/master/CODE_OF_CONDUCT.md
|
270
|
+
|
271
|
+
[security]: https://github.com/pboling/activerecord-transactionable/blob/master/SECURITY.md
|
239
272
|
|
240
|
-
[license]: LICENSE
|
241
273
|
[semver]: http://semver.org/
|
274
|
+
|
242
275
|
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
276
|
+
|
243
277
|
[railsbling]: http://www.railsbling.com
|
278
|
+
|
244
279
|
[peterboling]: http://www.peterboling.com
|
245
|
-
|
246
|
-
[
|
280
|
+
|
281
|
+
[issues]: https://github.com/pboling/activerecord-transactionable/issues
|
282
|
+
|
283
|
+
[contributing]: https://github.com/pboling/activerecord-transactionable/blob/master/CONTRIBUTING.md
|
284
|
+
|
285
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING)
|
286
|
+
|
287
|
+
[contributors]: https://github.com/pboling/activerecord-transactionable/graphs/contributors
|
288
|
+
|
289
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
|
290
|
+
|
291
|
+
[mailinglist]: http://groups.google.com/group/activerecord-transactionable-ruby
|
292
|
+
|
293
|
+
[source]: https://github.com/pboling/activerecord-transactionable/
|
294
|
+
|
295
|
+
[comment]: <> (Following links are used by Homepage)
|
296
|
+
|
297
|
+
[network]: https://github.com/pboling/activerecord-transactionable/network
|
298
|
+
|
299
|
+
[stargazers]: https://github.com/pboling/activerecord-transactionable/stargazers
|
300
|
+
|
301
|
+
[comment]: <> (Following links are used by README, Homepage)
|
302
|
+
|
303
|
+
[rubygems]: https://rubygems.org/gems/activerecord-transactionable
|
304
|
+
|
305
|
+
[depfu]: https://depfu.com/github/pboling/activerecord-transactionable?project_id=2653
|
306
|
+
|
307
|
+
[actions]: https://github.com/pboling/activerecord-transactionable/actions
|
308
|
+
|
309
|
+
[climate_coverage]: https://codeclimate.com/github/pboling/activerecord-transactionable/test_coverage
|
310
|
+
|
311
|
+
[gh_discussions]: https://github.com/pboling/activerecord-transactionable/discussions
|
312
|
+
|
313
|
+
[code_triage]: https://www.codetriage.com/pboling/activerecord-transactionable
|
314
|
+
|
315
|
+
[license-ref]: https://opensource.org/licenses/MIT
|
316
|
+
|
317
|
+
[codecov_coverage]: https://codecov.io/gh/pboling/activerecord-transactionable
|
318
|
+
|
319
|
+
[liberapay_donate]: https://liberapay.com/pboling/donate
|
320
|
+
|
321
|
+
[aboutme]: https://about.me/peter.boling
|
322
|
+
|
323
|
+
[angelme]: https://angel.co/peter-boling
|
324
|
+
|
325
|
+
[coderme]:http://coderwall.com/pboling
|
326
|
+
|
327
|
+
[politicme]: https://nationalprogressiveparty.org
|
328
|
+
|
329
|
+
[followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
|
330
|
+
|
331
|
+
[tweetme]: http://twitter.com/galtzo
|
332
|
+
|
333
|
+
[documentation]: https://rubydoc.info/github/pboling/activerecord-transactionable
|
334
|
+
|
335
|
+
[climate_maintainability]: https://codeclimate.com/github/pboling/activerecord-transactionable/maintainability
|
336
|
+
|
337
|
+
[chat]: https://gitter.im/pboling/activerecord-transactionable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
338
|
+
|
247
339
|
[blogpage]: http://www.railsbling.com/tags/activerecord-transactionable/
|
340
|
+
|
341
|
+
[maintenancee_policy]: https://guides.rubyonrails.org/maintenance_policy.html#security-issues
|
342
|
+
|
343
|
+
[gh_sponsors]: https://github.com/sponsors/pboling
|
data/SECURITY.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
| Version | Supported |
|
6
|
+
| ------- | ------------------ |
|
7
|
+
| 3.0.x | :white_check_mark: |
|
8
|
+
| 2.0.x | :white_check_mark: |
|
9
|
+
| 1.0.x | :x: |
|
10
|
+
| 0.0.x | :x: |
|
11
|
+
|
12
|
+
## Reporting a Vulnerability
|
13
|
+
|
14
|
+
Peter Boling is the primary maintainer of this gem. Please find a way to [contact him directly](https://railsbling.com/contact) to report the issue. Include as much relevant information as possible.
|
@@ -1,10 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Activerecord
|
2
4
|
module Transactionable
|
3
5
|
class Result
|
4
6
|
attr_reader :value, :result, :error, :type, :context, :nested, :attempt
|
7
|
+
|
5
8
|
def initialize(value, context:, transaction_open:, attempt:, error: nil, type: nil)
|
6
9
|
@value = value
|
7
|
-
@result = fail? ?
|
10
|
+
@result = fail? ? "fail" : "success"
|
8
11
|
@context = context
|
9
12
|
@nested = transaction_open ? true : false
|
10
13
|
@attempt = attempt
|
@@ -22,16 +25,16 @@ module Activerecord
|
|
22
25
|
|
23
26
|
def to_h(skip_error: nil)
|
24
27
|
diagnostic_data = {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
result: result,
|
29
|
+
type: type,
|
30
|
+
context: context,
|
31
|
+
nested: nested,
|
32
|
+
attempt: attempt
|
30
33
|
}
|
31
|
-
|
32
|
-
error
|
33
|
-
message
|
34
|
-
|
34
|
+
if !skip_error && error
|
35
|
+
diagnostic_data[:error] = error.class.to_s
|
36
|
+
diagnostic_data[:message] = error.message
|
37
|
+
end
|
35
38
|
diagnostic_data
|
36
39
|
end
|
37
40
|
|