hubbado-trailblazer 1.3.0 → 1.4.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: 236eb296eba6cbbfe62d8501dbb1a9984a3f286de4d3f1e61ec494713cc6fcc8
4
- data.tar.gz: ae8c2c869e63aba3503902e6d1b229d414f1a33d78378d20c1dcca9b48a7da2d
3
+ metadata.gz: f0d94f46fd55fd7b149ec18fb82e6923b8d828b4d9fbf4e23465bbfbd448688e
4
+ data.tar.gz: 5a63ac1ee253726b488acd45acbdaad37eb9af1fea81d9716f2089727aeae80f
5
5
  SHA512:
6
- metadata.gz: 4fff16b5816e5ece06716e01e9bf44f6fa6fc20d2db1abff64af8d526824ed1d47668bfbc6d3912e50697151e8582647d219973c86ecbcef53bb5a954a5f82e4
7
- data.tar.gz: 415fcc8495e1e3c9c099b502cf8dc4ed0a14dab9fc4dc66a4ff452f5c37eb76bcc558dc0d93a9449009f39df54c859031103b29f7f8f63d92a2fc8ed79ca94cf
6
+ metadata.gz: 7fb80170ecf81108173c6fcca1cf4271eb7e927f9bbc179cf2e66dc7e6f1e57b9681ecd99658af9184494330b46044d2c1cb60ab866e2c5c6efc8b08badc471f
7
+ data.tar.gz: afd335df6d8698d1fc89e722ba7fac1415e06b46f1722cb3796e6546d444005c98df54fb5cdbb9881ac5bd8703c8dc01d65898d7e834a68382b5be9188458bc2
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.4.0] - 2025-12-09
9
+
10
+ ### Added
11
+
12
+ - `policy_unauthorized_message` template method to customize the policy unauthorized exception message
13
+
8
14
  ## [1.3.0] - 2025-11-26
9
15
 
10
16
  ### Added
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubbado-trailblazer"
3
- s.version = "1.3.0"
3
+ s.version = "1.4.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"]
@@ -74,6 +74,10 @@ module Hubbado
74
74
  ctx
75
75
  end
76
76
 
77
+ template_method :policy_unauthorized_message do |ctx, operation_name:|
78
+ "User #{ctx[:current_user]&.id} not allowed to run #{operation_name}"
79
+ end
80
+
77
81
  def _run_runtime_options(ctx = {}, *dependencies)
78
82
  [_run_options(ctx), *dependencies]
79
83
  end
@@ -88,7 +92,15 @@ module Hubbado
88
92
 
89
93
  ctx = operation.send(operation_method, operation_arguments)
90
94
 
91
- result = Result.new(operation, ctx, trace_operation)
95
+ result = Result.new(
96
+ operation,
97
+ ctx,
98
+ trace_operation: trace_operation,
99
+ policy_unauthorized_message: policy_unauthorized_message(
100
+ ctx,
101
+ operation_name: operation.name
102
+ )
103
+ )
92
104
 
93
105
  yield(result) if block_given?
94
106
 
@@ -108,11 +120,13 @@ module Hubbado
108
120
 
109
121
  attr_reader :returned
110
122
  attr_reader :trace_operation
123
+ attr_reader :policy_unauthorized_message
111
124
 
112
- def initialize(operation, ctx, trace_operation)
125
+ def initialize(operation, ctx, trace_operation:, policy_unauthorized_message:)
113
126
  @operation = operation
114
127
  @ctx = ctx
115
128
  @trace_operation = trace_operation
129
+ @policy_unauthorized_message = policy_unauthorized_message
116
130
  end
117
131
 
118
132
  def log_level
@@ -207,13 +221,10 @@ module Hubbado
207
221
  end
208
222
 
209
223
  def raise_policy_failed
210
- current_user = ctx[:current_user]
211
- true_user = ctx[:true_user]
212
-
213
- msg = "User #{current_user&.id}/#{true_user&.id} (#{current_user&.roles&.join ', '}) " \
214
- "not allowed to run #{operation.name}"
215
-
216
- raise Hubbado::Trailblazer::Errors::Unauthorized.new(msg, ctx['result.policy.default'][:policy_result])
224
+ raise Hubbado::Trailblazer::Errors::Unauthorized.new(
225
+ policy_unauthorized_message,
226
+ ctx['result.policy.default'][:policy_result]
227
+ )
217
228
  end
218
229
 
219
230
  def success_executed?
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.3.0
4
+ version: 1.4.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.7.2
220
+ rubygems_version: 4.0.1
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.