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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9174956726d83240158a0102c0d7b498f59993cdfc68319c0b5501645e98f49
4
- data.tar.gz: 5a21376185e673110ef2226d347a9f6581804fcff88a2ac375f5fc1b76e8f6f2
3
+ metadata.gz: cc1e7ef446a048939d8e419f77946db6f9ee7621ddad0fed3108fa03129426d9
4
+ data.tar.gz: e45c7a1c4dc5f3baf42897396c227f34481446a2e3721d9ed4fc5f6a8497b4d9
5
5
  SHA512:
6
- metadata.gz: 35d2de94d943e8bcd649cc5310034eee506f6d73be2efdd1eed0645c720d669d031e600e0e34bf8cbb5a51e25ce76c5f76431c77ea89f575acb594fc325dcfb6
7
- data.tar.gz: a5e49d65ce04acbbd4805c8655403e404867e9a77a4fc1e58c27fc4df766b26a2cf029a66ff2ee5ded91f74a2344fb6a2f5d5332e6fd96c5233b63130aac048b
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
- ## [1.0.0] - 2024-11-02
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-2025 Hanakai team
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
-
@@ -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 = "bin"
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 rom transaction support to operations
12
+ # Add Rom transaction support to operations.
13
13
  #
14
- # When this extension is included, you can use a `#transaction` method
15
- # to wrap the desired steps in a rom transaction. If any of the steps
16
- # returns a `Dry::Monads::Result::Failure`, the transaction will be rolled
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
- # container via a `#rom` method.
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. You can change this
50
- # when including the extension:
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[gateway: :my_gateway]
55
+ # include Dry::Operation::Extensions::ROM[
56
+ # gateway: :my_gateway,
57
+ # isolation: :serializable
58
+ # ]
54
59
  # ```
55
60
  #
56
- # Or you can change it at runtime:
61
+ # You can also override the gateway and/or transaction options at runtime:
57
62
  #
58
63
  # ```ruby
59
- # user = transaction(gateway: :my_gateway) do
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 ROM extension, you need to define a #rom method \
104
- that returns the ROM container
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!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  class Operation
5
- VERSION = "1.0.1"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
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.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team
8
- bindir: bin
8
+ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: