Skip to content

Conversation

ericproulx
Copy link
Contributor

Remove namespace_reverse_stackable from public DSL interface

Summary

This PR removes the namespace_reverse_stackable method from the public DSL interface in Grape::DSL::Settings and replaces its usage with direct access to inheritable_setting.namespace_reverse_stackable.

Changes Made

DSL Interface Changes

  • Removed namespace_reverse_stackable method from Grape::DSL::Settings
  • Updated Grape::DSL::Desc to use direct inheritable_setting access instead of namespace_setting
  • Updated Grape::DSL::RequestResponse to use direct inheritable_setting access for rescue handlers

Test Improvements

  • Simplified test setup in request_response_spec.rb by extending Grape::DSL::Settings instead of manually stubbing methods
  • Updated test expectations to verify actual behavior instead of mocking internal method calls
  • Removed unnecessary manual stubbing of namespace methods

Benefits

  1. Cleaner API: Removes an internal implementation detail from the public DSL interface
  2. Better Test Coverage: Tests now verify actual behavior rather than just method calls
  3. Simplified Code: Reduces the number of wrapper methods in the DSL
  4. Direct Access: Allows direct manipulation of inheritable settings when needed

Files Modified

  • lib/grape/dsl/desc.rb - Use direct inheritable_setting access
  • lib/grape/dsl/request_response.rb - Use direct inheritable_setting access for rescue handlers
  • lib/grape/dsl/settings.rb - Remove namespace_reverse_stackable method
  • spec/grape/dsl/request_response_spec.rb - Update tests to verify actual behavior

Breaking Changes

This change removes a public method from the DSL interface. However, this method was primarily used internally and direct access to inheritable_setting.namespace_reverse_stackable provides the same functionality.

Testing

All existing tests pass with the updated implementation. The rescue_from functionality continues to work as expected with the new direct access pattern.

@ericproulx ericproulx marked this pull request as ready for review September 22, 2025 08:42
@ericproulx ericproulx requested a review from dblock September 22, 2025 08:42
- Remove namespace_reverse_stackable method from Grape::DSL::Settings
- Replace direct calls to namespace_reverse_stackable with inheritable_setting.namespace_reverse_stackable
- Update rescue_from implementation to use direct inheritable_setting access
- Update tests to verify actual behavior instead of mocking internal methods
- Simplify test setup by extending Grape::DSL::Settings instead of manually stubbing methods
@ericproulx ericproulx force-pushed the remove_namespace_reverse_stackable_from_public_interface branch from 0ee5f33 to 8ee2d4f Compare September 22, 2025 08:44
@ericproulx ericproulx closed this Sep 26, 2025
@ericproulx ericproulx deleted the remove_namespace_reverse_stackable_from_public_interface branch September 26, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant