Skip to content

Commit f35caa0

Browse files
authored
Merge pull request #2596 from ruby-grape/private_namespace_reverse_stackable_with_hash
Private namespace reverse stackable with hash
2 parents 829c254 + 924953d commit f35caa0

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [#2593](https://github.com/ruby-grape/grape/pull/2593): Fix warning message when overriding global registry key - [@ericproulx](https://github.com/ericproulx).
2121
* [#2594](https://github.com/ruby-grape/grape/pull/2594): Fix routes memoization - [@ericproulx](https://github.com/ericproulx).
2222
* [#2595](https://github.com/ruby-grape/grape/pull/2595): Keep `within_namespace` as part of our internal api - [@ericproulx](https://github.com/ericproulx).
23+
* [#2596](https://github.com/ruby-grape/grape/pull/2596): Remove `namespace_reverse_stackable_with_hash` from public scope - [@ericproulx](https://github.com/ericproulx).
2324
* Your contribution here.
2425

2526
### 2.4.0 (2025-06-18)

lib/grape/dsl/settings.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ def namespace_stackable_with_hash(key)
8989
settings.each_with_object({}) { |value, result| result.deep_merge!(value) }
9090
end
9191

92-
def namespace_reverse_stackable_with_hash(key)
93-
settings = get_or_set :namespace_reverse_stackable, key, nil
94-
return if settings.blank?
95-
96-
settings.each_with_object({}) do |setting, result|
97-
result.merge!(setting) { |_k, s1, _s2| s1 }
98-
end
99-
end
100-
10192
private
10293

10394
# Execute the block within a context where our inheritable settings are forked

lib/grape/endpoint.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def build_stack
333333
default_error_formatter: namespace_inheritable(:default_error_formatter),
334334
error_formatters: namespace_stackable_with_hash(:error_formatters),
335335
rescue_options: namespace_stackable_with_hash(:rescue_options),
336-
rescue_handlers: namespace_reverse_stackable_with_hash(:rescue_handlers),
336+
rescue_handlers: rescue_handlers,
337337
base_only_rescue_handlers: namespace_stackable_with_hash(:base_only_rescue_handlers),
338338
all_rescue_handler: namespace_inheritable(:all_rescue_handler),
339339
grape_exceptions_rescue_handler: namespace_inheritable(:grape_exceptions_rescue_handler)
@@ -377,5 +377,14 @@ def build_response_cookies
377377
def lint?
378378
namespace_inheritable(:lint) || Grape.config.lint
379379
end
380+
381+
def rescue_handlers
382+
rescue_handlers = inheritable_setting.namespace_reverse_stackable[:rescue_handlers]
383+
return if rescue_handlers.blank?
384+
385+
rescue_handlers.each_with_object({}) do |rescue_handler, result|
386+
result.merge!(rescue_handler) { |_k, s1, _s2| s1 }
387+
end
388+
end
380389
end
381390
end

0 commit comments

Comments
 (0)