hubbado-trailblazer 1.2.0 → 1.3.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 +6 -0
- data/hubbado-trailblazer.gemspec +1 -1
- data/lib/hubbado/trailblazer/run_operation.rb +31 -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: 236eb296eba6cbbfe62d8501dbb1a9984a3f286de4d3f1e61ec494713cc6fcc8
|
|
4
|
+
data.tar.gz: ae8c2c869e63aba3503902e6d1b229d414f1a33d78378d20c1dcca9b48a7da2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4fff16b5816e5ece06716e01e9bf44f6fa6fc20d2db1abff64af8d526824ed1d47668bfbc6d3912e50697151e8582647d219973c86ecbcef53bb5a954a5f82e4
|
|
7
|
+
data.tar.gz: 415fcc8495e1e3c9c099b502cf8dc4ed0a14dab9fc4dc66a4ff452f5c37eb76bcc558dc0d93a9449009f39df54c859031103b29f7f8f63d92a2fc8ed79ca94cf
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.0] - 2025-11-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support for `result.not_found { ... }` block to handle operations with `:not_found` terminus.
|
|
13
|
+
|
|
8
14
|
## [1.2.0] - 2025-07-19
|
|
9
15
|
|
|
10
16
|
### Added
|
data/hubbado-trailblazer.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "hubbado-trailblazer"
|
|
3
|
-
s.version = "1.
|
|
3
|
+
s.version = "1.3.0"
|
|
4
4
|
s.summary = "Enhanced Trailblazer operation utilities for Ruby applications with improved error handling, operation execution patterns, and ActiveRecord integration."
|
|
5
5
|
|
|
6
6
|
s.authors = ["Hubbado Devs"]
|
|
@@ -16,6 +16,10 @@ module Hubbado
|
|
|
16
16
|
# result.raise_policy_failed
|
|
17
17
|
# end
|
|
18
18
|
#
|
|
19
|
+
# result.not_found do |ctx|
|
|
20
|
+
# ...
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
19
23
|
# result.validation_failed do |ctx|
|
|
20
24
|
# ...
|
|
21
25
|
# end
|
|
@@ -34,6 +38,9 @@ module Hubbado
|
|
|
34
38
|
# If there is a policy failure and you have not implemented
|
|
35
39
|
# `result.policy_failed` then an exception will be raised.
|
|
36
40
|
#
|
|
41
|
+
# If the operation has not_found terminus and you have not
|
|
42
|
+
# implemented `result.not_found` then ActiveRecord::RecordNotFound will be raised.
|
|
43
|
+
#
|
|
37
44
|
# If the operation fails (due to non-policy error) and you have not
|
|
38
45
|
# implemented `result.otherwise` then an exception will be raised.
|
|
39
46
|
#
|
|
@@ -87,7 +94,9 @@ module Hubbado
|
|
|
87
94
|
|
|
88
95
|
if ctx['result.policy.default']&.failure?
|
|
89
96
|
result.raise_policy_failed unless result.policy_failed_executed?
|
|
90
|
-
elsif
|
|
97
|
+
elsif !result.not_found_executed? && ctx.terminus.to_h[:semantic] == :not_found
|
|
98
|
+
result.raise_not_found
|
|
99
|
+
elsif ctx.failure? && !result.validation_failed_executed? && !result.not_found_executed? && !result.otherwise_executed?
|
|
91
100
|
result.raise_operation_failed
|
|
92
101
|
end
|
|
93
102
|
|
|
@@ -159,6 +168,16 @@ module Hubbado
|
|
|
159
168
|
@returned
|
|
160
169
|
end
|
|
161
170
|
|
|
171
|
+
def not_found
|
|
172
|
+
return unless ctx.terminus.to_h[:semantic] == :not_found
|
|
173
|
+
|
|
174
|
+
@not_found_executed = true
|
|
175
|
+
@returned = yield(ctx)
|
|
176
|
+
|
|
177
|
+
logger.send(log_level, "Not found block executed for operation #{operation}")
|
|
178
|
+
@returned
|
|
179
|
+
end
|
|
180
|
+
|
|
162
181
|
def otherwise
|
|
163
182
|
return if executed?
|
|
164
183
|
|
|
@@ -169,6 +188,12 @@ module Hubbado
|
|
|
169
188
|
@returned
|
|
170
189
|
end
|
|
171
190
|
|
|
191
|
+
def raise_not_found
|
|
192
|
+
msg = "Record for operation #{operation.name} not found"
|
|
193
|
+
|
|
194
|
+
raise ActiveRecord::RecordNotFound, msg
|
|
195
|
+
end
|
|
196
|
+
|
|
172
197
|
def raise_operation_failed
|
|
173
198
|
msg = "Operation #{operation.name} failed"
|
|
174
199
|
|
|
@@ -203,6 +228,10 @@ module Hubbado
|
|
|
203
228
|
!!@validation_failed_executed
|
|
204
229
|
end
|
|
205
230
|
|
|
231
|
+
def not_found_executed?
|
|
232
|
+
!!@not_found_executed
|
|
233
|
+
end
|
|
234
|
+
|
|
206
235
|
def otherwise_executed?
|
|
207
236
|
!!@otherwise_executed
|
|
208
237
|
end
|
|
@@ -211,6 +240,7 @@ module Hubbado
|
|
|
211
240
|
success_executed? ||
|
|
212
241
|
policy_failed_executed? ||
|
|
213
242
|
validation_failed_executed? ||
|
|
243
|
+
not_found_executed? ||
|
|
214
244
|
otherwise_executed?
|
|
215
245
|
end
|
|
216
246
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hubbado-trailblazer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hubbado Devs
|
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
217
217
|
- !ruby/object:Gem::Version
|
|
218
218
|
version: '0'
|
|
219
219
|
requirements: []
|
|
220
|
-
rubygems_version: 3.
|
|
220
|
+
rubygems_version: 3.7.2
|
|
221
221
|
specification_version: 4
|
|
222
222
|
summary: Enhanced Trailblazer operation utilities for Ruby applications with improved
|
|
223
223
|
error handling, operation execution patterns, and ActiveRecord integration.
|