dry-operation 1.0.0 → 1.0.1
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 +35 -0
- data/LICENSE +2 -1
- data/README.md +9 -6
- data/dry-operation.gemspec +30 -21
- data/lib/dry/operation/extensions/active_record.rb +26 -25
- data/lib/dry/operation/extensions/rom.rb +17 -17
- data/lib/dry/operation/extensions/sequel.rb +17 -17
- data/lib/dry/operation/version.rb +1 -1
- metadata +60 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9174956726d83240158a0102c0d7b498f59993cdfc68319c0b5501645e98f49
|
|
4
|
+
data.tar.gz: 5a21376185e673110ef2226d347a9f6581804fcff88a2ac375f5fc1b76e8f6f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35d2de94d943e8bcd649cc5310034eee506f6d73be2efdd1eed0645c720d669d031e600e0e34bf8cbb5a51e25ce76c5f76431c77ea89f575acb594fc325dcfb6
|
|
7
|
+
data.tar.gz: a5e49d65ce04acbbd4805c8655403e404867e9a77a4fc1e58c27fc4df766b26a2cf029a66ff2ee5ded91f74a2344fb6a2f5d5332e6fd96c5233b63130aac048b
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
### Deprecated
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
### Security
|
|
21
|
+
|
|
22
|
+
## [1.0.1] - 2025-10-24
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- 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
|
+
|
|
28
|
+
## [1.0.0] - 2024-11-02
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- 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-2025 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,3 +18,4 @@ 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/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
<!--- This file is synced from hanakai-rb/repo-sync -->
|
|
2
|
+
|
|
3
|
+
[rubygem]: https://rubygems.org/gems/dry-operation
|
|
2
4
|
[actions]: https://github.com/dry-rb/dry-operation/actions
|
|
3
5
|
|
|
4
|
-
# dry-operation [][
|
|
6
|
+
# dry-operation [][rubygem] [][actions]
|
|
5
7
|
|
|
6
8
|
## Links
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
- [User documentation](https://dry-rb.org/gems/dry-operation)
|
|
11
|
+
- [API documentation](http://rubydoc.info/gems/dry-operation)
|
|
12
|
+
- [Forum](https://discourse.dry-rb.org)
|
|
11
13
|
|
|
12
14
|
## License
|
|
13
15
|
|
|
14
|
-
See
|
|
16
|
+
See `LICENSE` file.
|
|
17
|
+
|
data/dry-operation.gemspec
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
|
|
4
|
+
|
|
3
5
|
lib = File.expand_path("lib", __dir__)
|
|
4
|
-
$LOAD_PATH.
|
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
7
|
require "dry/operation/version"
|
|
6
8
|
|
|
7
9
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name
|
|
9
|
-
spec.
|
|
10
|
-
spec.
|
|
11
|
-
spec.
|
|
12
|
-
spec.
|
|
13
|
-
|
|
14
|
-
spec.
|
|
15
|
-
|
|
16
|
-
spec.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
spec.name = "dry-operation"
|
|
11
|
+
spec.authors = ["Hanakai team"]
|
|
12
|
+
spec.email = ["info@hanakai.org"]
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.version = Dry::Operation::VERSION.dup
|
|
15
|
+
|
|
16
|
+
spec.summary = "A domain specific language for composable business transaction workflows."
|
|
17
|
+
spec.description = spec.summary
|
|
18
|
+
spec.homepage = "https://dry-rb.org/gems/dry-operation"
|
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-operation.gemspec", "lib/**/*"]
|
|
20
|
+
spec.bindir = "bin"
|
|
21
|
+
spec.executables = []
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
25
|
+
|
|
26
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
27
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-operation/blob/main/CHANGELOG.md"
|
|
28
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-operation"
|
|
29
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-operation/issues"
|
|
30
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
|
|
24
31
|
|
|
25
32
|
spec.required_ruby_version = ">= 3.1.0"
|
|
26
|
-
spec.add_dependency "zeitwerk", "~> 2.6"
|
|
27
|
-
spec.add_dependency "dry-monads", "~> 1.6"
|
|
28
33
|
|
|
29
|
-
spec.
|
|
30
|
-
spec.
|
|
34
|
+
spec.add_runtime_dependency "dry-monads", "~> 1.6"
|
|
35
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
36
|
+
spec.add_development_dependency "bundler"
|
|
37
|
+
spec.add_development_dependency "rspec"
|
|
38
|
+
spec.add_development_dependency "yard"
|
|
31
39
|
end
|
|
40
|
+
|
|
@@ -96,33 +96,34 @@ module Dry
|
|
|
96
96
|
@options = options
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
def included(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
99
|
+
def included(_klass)
|
|
100
|
+
default_connection = @connection
|
|
101
|
+
default_options = @options
|
|
102
|
+
|
|
103
|
+
# @!method transaction(connection = ActiveRecord::Base, **options, &steps)
|
|
104
|
+
# Wrap the given steps in an ActiveRecord transaction.
|
|
105
|
+
#
|
|
106
|
+
# If any of the steps returns a `Dry::Monads::Result::Failure`, the
|
|
107
|
+
# transaction will be rolled back and `:halt` will be thrown with the
|
|
108
|
+
# failure as its value.
|
|
109
|
+
#
|
|
110
|
+
# @param connection [#transaction] The class/object to use
|
|
111
|
+
# @param options [Hash] Additional options for the ActiveRecord transaction
|
|
112
|
+
# @yieldreturn [Object] the result of the block
|
|
113
|
+
# @see Dry::Operation#steps
|
|
114
|
+
# @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-transaction
|
|
115
|
+
define_method(:transaction) do |connection = default_connection, **opts, &steps|
|
|
116
|
+
intercepting_failure do
|
|
117
|
+
result = nil
|
|
118
|
+
connection.transaction(**default_options.merge(opts)) do
|
|
119
|
+
intercepting_failure(->(failure) {
|
|
120
|
+
result = failure
|
|
121
|
+
raise ::ActiveRecord::Rollback
|
|
122
|
+
}) do
|
|
123
|
+
result = steps.()
|
|
123
124
|
end
|
|
124
|
-
result
|
|
125
125
|
end
|
|
126
|
+
result
|
|
126
127
|
end
|
|
127
128
|
end
|
|
128
129
|
end
|
|
@@ -95,26 +95,26 @@ module Dry
|
|
|
95
95
|
@gateway = gateway
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
def included(
|
|
99
|
-
|
|
100
|
-
klass.define_method(:transaction) do |gateway: default_gateway, &steps|
|
|
101
|
-
raise Dry::Operation::ExtensionError, <<~MSG unless respond_to?(:rom)
|
|
102
|
-
When using the ROM extension, you need to define a #rom method \
|
|
103
|
-
that returns the ROM container
|
|
104
|
-
MSG
|
|
98
|
+
def included(_klass)
|
|
99
|
+
default_gateway = @gateway
|
|
105
100
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
define_method(:transaction) do |gateway: default_gateway, &steps|
|
|
102
|
+
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
|
|
105
|
+
MSG
|
|
106
|
+
|
|
107
|
+
intercepting_failure do
|
|
108
|
+
result = nil
|
|
109
|
+
rom.gateways[gateway].transaction do |t|
|
|
110
|
+
intercepting_failure(->(failure) {
|
|
111
|
+
result = failure
|
|
112
|
+
t.rollback!
|
|
113
|
+
}) do
|
|
114
|
+
result = steps.()
|
|
115
115
|
end
|
|
116
|
-
result
|
|
117
116
|
end
|
|
117
|
+
result
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
end
|
|
@@ -81,26 +81,26 @@ module Dry
|
|
|
81
81
|
@options = options
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
def included(
|
|
85
|
-
|
|
86
|
-
klass.define_method(:transaction) do |**opts, &steps|
|
|
87
|
-
raise Dry::Operation::ExtensionError, <<~MSG unless respond_to?(:db)
|
|
88
|
-
When using the Sequel extension, you need to define a #db method \
|
|
89
|
-
that returns the Sequel database object
|
|
90
|
-
MSG
|
|
84
|
+
def included(_klass)
|
|
85
|
+
default_options = @options
|
|
91
86
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
define_method(:transaction) do |**opts, &steps|
|
|
88
|
+
raise Dry::Operation::ExtensionError, <<~MSG unless respond_to?(:db)
|
|
89
|
+
When using the Sequel extension, you need to define a #db method \
|
|
90
|
+
that returns the Sequel database object
|
|
91
|
+
MSG
|
|
92
|
+
|
|
93
|
+
intercepting_failure do
|
|
94
|
+
result = nil
|
|
95
|
+
db.transaction(**default_options.merge(opts)) do
|
|
96
|
+
intercepting_failure(->(failure) {
|
|
97
|
+
result = failure
|
|
98
|
+
raise ::Sequel::Rollback
|
|
99
|
+
}) do
|
|
100
|
+
result = steps.()
|
|
101
101
|
end
|
|
102
|
-
result
|
|
103
102
|
end
|
|
103
|
+
result
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
metadata
CHANGED
|
@@ -1,52 +1,95 @@
|
|
|
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.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Hanakai team
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: dry-monads
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '1.6'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '1.6'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: zeitwerk
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '2.6'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
41
|
-
|
|
39
|
+
version: '2.6'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: bundler
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: yard
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
description: A domain specific language for composable business transaction workflows.
|
|
42
83
|
email:
|
|
43
|
-
-
|
|
84
|
+
- info@hanakai.org
|
|
44
85
|
executables: []
|
|
45
86
|
extensions: []
|
|
46
87
|
extra_rdoc_files:
|
|
47
|
-
-
|
|
88
|
+
- CHANGELOG.md
|
|
48
89
|
- LICENSE
|
|
90
|
+
- README.md
|
|
49
91
|
files:
|
|
92
|
+
- CHANGELOG.md
|
|
50
93
|
- LICENSE
|
|
51
94
|
- README.md
|
|
52
95
|
- dry-operation.gemspec
|
|
@@ -63,13 +106,11 @@ homepage: https://dry-rb.org/gems/dry-operation
|
|
|
63
106
|
licenses:
|
|
64
107
|
- MIT
|
|
65
108
|
metadata:
|
|
66
|
-
|
|
109
|
+
allowed_push_host: https://rubygems.org
|
|
67
110
|
changelog_uri: https://github.com/dry-rb/dry-operation/blob/main/CHANGELOG.md
|
|
68
|
-
documentation_uri: https://dry-rb.org/gems/dry-operation
|
|
69
|
-
funding_uri: https://github.com/sponsors/hanami
|
|
70
|
-
label: dry-operation
|
|
71
111
|
source_code_uri: https://github.com/dry-rb/dry-operation
|
|
72
|
-
|
|
112
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-operation/issues
|
|
113
|
+
funding_uri: https://github.com/sponsors/hanami
|
|
73
114
|
rdoc_options: []
|
|
74
115
|
require_paths:
|
|
75
116
|
- lib
|
|
@@ -84,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
84
125
|
- !ruby/object:Gem::Version
|
|
85
126
|
version: '0'
|
|
86
127
|
requirements: []
|
|
87
|
-
rubygems_version: 3.
|
|
88
|
-
signing_key:
|
|
128
|
+
rubygems_version: 3.6.9
|
|
89
129
|
specification_version: 4
|
|
90
130
|
summary: A domain specific language for composable business transaction workflows.
|
|
91
131
|
test_files: []
|