dry-operation 1.0.1 → 1.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 +4 -4
- data/CHANGELOG.md +23 -4
- data/LICENSE +1 -2
- data/dry-operation.gemspec +2 -2
- data/lib/dry/operation/extensions/rom.rb +30 -20
- data/lib/dry/operation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc1e7ef446a048939d8e419f77946db6f9ee7621ddad0fed3108fa03129426d9
|
|
4
|
+
data.tar.gz: e45c7a1c4dc5f3baf42897396c227f34481446a2e3721d9ed4fc5f6a8497b4d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b914c5124f131eb116ce48e919cc38c0cc00c5f70893ae9629c7eb72dd8e35dcd6e709bcf262019104310d4c0035da7e0097b8ee715bdd5585a57458dd6f315
|
|
7
|
+
data.tar.gz: 4a7d4c96fce72d09f18e4da94dc2db0e49fb1cf99b3acc4ca56f1fbb0e3d9baeed1a862ea0bdf282128afc1d81135175bdbeca469e2605337edbb04c38befd62
|
data/CHANGELOG.md
CHANGED
|
@@ -19,17 +19,36 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
|
|
|
19
19
|
|
|
20
20
|
### Security
|
|
21
21
|
|
|
22
|
+
[Unreleased]: https://github.com/dry-rb/dry-operation/compare/v1.1.0...main
|
|
23
|
+
|
|
24
|
+
## [1.1.0] - 2026-02-06
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- In Rom extension, allow transaction options to be passed via `#transaction`. (@wuarmin in #37)
|
|
29
|
+
```ruby
|
|
30
|
+
# Set options at extension time (used for all transactions within the class):
|
|
31
|
+
include Dry::Operation::Extensions::ROM[isolation: :serializable]
|
|
32
|
+
|
|
33
|
+
# Or per-transaction, in instance methods. These will be merged with the extension-level
|
|
34
|
+
# options.
|
|
35
|
+
transaction(savepoint: true) do
|
|
36
|
+
# This transaction will have options `isolation: :serializable, savepoint: true`
|
|
37
|
+
end
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
[1.1.0]: https://github.com/dry-rb/dry-operation/compare/v1.0.1...v1.1.0
|
|
41
|
+
|
|
22
42
|
## [1.0.1] - 2025-10-24
|
|
23
43
|
|
|
24
44
|
### Changed
|
|
25
45
|
|
|
26
46
|
- Define `#transaction` method in extension modules themselves (which are included into the operation class), rather than directly on the operation class itself. This adheres to typical Ruby inheritance-based method lookup, and allows for overloads of `#transaction` to be defined directly in the operation class or mixed in via other modules. (@timriley in #33)
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
[1.0.1]: https://github.com/dry-rb/dry-operation/compare/v1.0.0...v1.0.1
|
|
49
|
+
|
|
50
|
+
## 1.0.0 - 2024-11-02
|
|
29
51
|
|
|
30
52
|
### Added
|
|
31
53
|
|
|
32
54
|
- Initial release. (@waiting-for-dev)
|
|
33
|
-
|
|
34
|
-
[1.0.1]: https://github.com/dry-rb/dry-operation/compare/v1.0.0...v1.0.1
|
|
35
|
-
[1.0.0]: https://github.com/dry-rb/dry-operation/releases/tag/v1.0.0
|
data/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2015-
|
|
3
|
+
Copyright (c) 2015-2026 Hanakai team
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -18,4 +18,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
18
18
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
20
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
data/dry-operation.gemspec
CHANGED
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.description = spec.summary
|
|
18
18
|
spec.homepage = "https://dry-rb.org/gems/dry-operation"
|
|
19
19
|
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-operation.gemspec", "lib/**/*"]
|
|
20
|
-
spec.bindir = "
|
|
21
|
-
spec.executables = []
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
23
|
|
|
24
24
|
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
@@ -9,15 +9,14 @@ end
|
|
|
9
9
|
module Dry
|
|
10
10
|
class Operation
|
|
11
11
|
module Extensions
|
|
12
|
-
# Add
|
|
12
|
+
# Add Rom transaction support to operations.
|
|
13
13
|
#
|
|
14
|
-
# When this extension is included, you can use a `#transaction` method
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
# back and, as usual, the rest of the flow will be skipped.
|
|
14
|
+
# When this extension is included, you can use a `#transaction` method to wrap the desired
|
|
15
|
+
# steps in a Rom transaction. If any of the steps returns a `Dry::Monads::Result::Failure`,
|
|
16
|
+
# the transaction will be rolled back and, as usual, the rest of the flow will be skipped.
|
|
18
17
|
#
|
|
19
|
-
# The extension expects the including class to give access to the rom
|
|
20
|
-
#
|
|
18
|
+
# The extension expects the including class to give access to the Rom container via a `#rom`
|
|
19
|
+
# method.
|
|
21
20
|
#
|
|
22
21
|
# ```ruby
|
|
23
22
|
# require "dry/operation/extensions/rom"
|
|
@@ -46,18 +45,27 @@ module Dry
|
|
|
46
45
|
# end
|
|
47
46
|
# ```
|
|
48
47
|
#
|
|
49
|
-
# By default, the `:default` gateway will be used
|
|
50
|
-
#
|
|
48
|
+
# By default, the `:default` gateway will be used and no additional
|
|
49
|
+
# options will be passed to the Rom transaction.
|
|
50
|
+
#
|
|
51
|
+
# You can change the default gateway and transaction options when
|
|
52
|
+
# including the extension:
|
|
51
53
|
#
|
|
52
54
|
# ```ruby
|
|
53
|
-
# include Dry::Operation::Extensions::ROM[
|
|
55
|
+
# include Dry::Operation::Extensions::ROM[
|
|
56
|
+
# gateway: :my_gateway,
|
|
57
|
+
# isolation: :serializable
|
|
58
|
+
# ]
|
|
54
59
|
# ```
|
|
55
60
|
#
|
|
56
|
-
#
|
|
61
|
+
# You can also override the gateway and/or transaction options at runtime:
|
|
57
62
|
#
|
|
58
63
|
# ```ruby
|
|
59
|
-
# user = transaction(
|
|
60
|
-
#
|
|
64
|
+
# user = transaction(
|
|
65
|
+
# gateway: :my_gateway,
|
|
66
|
+
# isolation: :serializable
|
|
67
|
+
# ) do
|
|
68
|
+
# # ...
|
|
61
69
|
# end
|
|
62
70
|
# ```
|
|
63
71
|
#
|
|
@@ -84,29 +92,31 @@ module Dry
|
|
|
84
92
|
# Include the extension providing a custom gateway
|
|
85
93
|
#
|
|
86
94
|
# @param gateway [Symbol] the rom gateway to use
|
|
87
|
-
def self.[](gateway: DEFAULT_GATEWAY)
|
|
88
|
-
Builder.new(gateway: gateway)
|
|
95
|
+
def self.[](gateway: DEFAULT_GATEWAY, **options)
|
|
96
|
+
Builder.new(gateway: gateway, **options)
|
|
89
97
|
end
|
|
90
98
|
|
|
91
99
|
# @api private
|
|
92
100
|
class Builder < Module
|
|
93
|
-
def initialize(gateway
|
|
101
|
+
def initialize(gateway:, **options)
|
|
94
102
|
super()
|
|
95
103
|
@gateway = gateway
|
|
104
|
+
@options = options
|
|
96
105
|
end
|
|
97
106
|
|
|
98
107
|
def included(_klass)
|
|
99
108
|
default_gateway = @gateway
|
|
109
|
+
default_options = @options
|
|
100
110
|
|
|
101
|
-
define_method(:transaction) do |gateway: default_gateway, &steps|
|
|
111
|
+
define_method(:transaction) do |gateway: default_gateway, **opts, &steps|
|
|
102
112
|
raise Dry::Operation::ExtensionError, <<~MSG unless respond_to?(:rom)
|
|
103
|
-
When using the
|
|
104
|
-
that returns the
|
|
113
|
+
When using the Rom extension, you need to define a #rom method \
|
|
114
|
+
that returns the Rom container
|
|
105
115
|
MSG
|
|
106
116
|
|
|
107
117
|
intercepting_failure do
|
|
108
118
|
result = nil
|
|
109
|
-
rom.gateways[gateway].transaction do |t|
|
|
119
|
+
rom.gateways[gateway].transaction(**default_options.merge(opts)) do |t|
|
|
110
120
|
intercepting_failure(->(failure) {
|
|
111
121
|
result = failure
|
|
112
122
|
t.rollback!
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-operation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hanakai team
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|