Skip to content

Conversation

ericproulx
Copy link
Contributor

Remove namespace_stackable and namespace_inheritable from public API

Summary

This PR refactors the internal implementation of Grape's namespace configuration system by removing public access to namespace_stackable and namespace_inheritable methods while maintaining backward compatibility for public-facing APIs.

Changes Made

Core Refactoring

  • API Instance: Simplified cascade method implementation to use inheritable_setting directly
  • Namespace Class: Added proper equality methods (eql?, ==, hash) for better object comparison
  • DSL Modules: Updated all DSL modules to use internal configuration access instead of public methods

Files Modified

  • lib/grape/api/instance.rb - Refactored cascade method and removed public access methods
  • lib/grape/namespace.rb - Added equality methods for proper namespace comparison
  • lib/grape/dsl/*.rb - Updated DSL modules to use internal configuration
  • lib/grape/endpoint.rb - Refactored to use internal configuration access
  • lib/grape/middleware/auth/dsl.rb - Updated authentication DSL
  • lib/grape/validations/*.rb - Updated validation modules

Test Updates

  • Updated all corresponding test files to reflect internal API changes
  • Maintained test coverage while adapting to new internal structure
  • Removed tests for now-private methods

Benefits

  1. Cleaner Public API: Removes internal implementation details from public interface
  2. Better Encapsulation: Internal configuration management is now properly encapsulated
  3. Maintained Compatibility: Public-facing methods continue to work as expected
  4. Improved Maintainability: Internal refactoring makes the codebase easier to maintain

Breaking Changes

None - This is an internal refactoring that maintains backward compatibility for all public APIs.

Testing

  • All existing tests have been updated to work with the new internal structure
  • No new functionality has been added, only internal implementation changes
  • Test coverage remains comprehensive

Migration Guide

No migration required - this change is transparent to end users of the Grape gem.

Related Issues

This refactoring addresses internal code organization and API cleanliness without affecting external functionality.

@ericproulx ericproulx force-pushed the remove_namespace_stackable_and_inheritable_from_public_space branch from a8dada4 to 2f69d09 Compare September 28, 2025 19:27
@ericproulx ericproulx requested a review from dblock September 28, 2025 19:27
@ericproulx ericproulx force-pushed the remove_namespace_stackable_and_inheritable_from_public_space branch 3 times, most recently from 2e12646 to 896892d Compare September 28, 2025 19:37
@dblock
Copy link
Member

dblock commented Sep 29, 2025

Failures in dry_validation look legit.

@ericproulx ericproulx force-pushed the remove_namespace_stackable_and_inheritable_from_public_space branch from 896892d to 8f90af9 Compare September 29, 2025 19:52
- Refactor internal implementation to use inheritable_setting directly
- Remove public access to namespace_stackable and namespace_inheritable methods
- Update DSL modules to use internal configuration access
- Add equality methods to Namespace class for proper comparison
- Update tests to reflect internal API changes
- Maintain backward compatibility for public-facing methods
@ericproulx ericproulx force-pushed the remove_namespace_stackable_and_inheritable_from_public_space branch from 8f90af9 to a562a50 Compare September 29, 2025 19:56

Metrics/AbcSize:
Max: 50
Max: 80 # TODO: revert to 50 once the refactor of public api is done.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just run rubocop -a ; rubocop --auto-gen-config.

@dblock dblock merged commit a113803 into master Sep 29, 2025
103 checks passed
@dblock dblock deleted the remove_namespace_stackable_and_inheritable_from_public_space branch September 29, 2025 21:41
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.

2 participants