Refactor route_setting internal usage to use inheritable_setting.route#2601
Merged
Conversation
- Remove unset, unset_namespace_stackable, and namespace_inheritable_to_nil methods - Simplify reset_validations! to call delete directly instead of through wrappers - Enhance BaseInheritable#delete to accept multiple keys - Improve without_root_prefix_and_versioning with proper ensure block cleanup - Update tests to verify actual behavior instead of method calls These methods were internal APIs not intended for public use. Removing them reduces the public API surface and simplifies the codebase.
- Replace dynamic method generation with explicit method definitions - Simplify get_or_set to work directly with setting objects instead of type symbols - Update logger to directly access global settings for better performance - Improve test coverage to focus on actual behavior rather than delegation - Remove unnecessary complexity in settings DSL implementation
…tency - Remove method indirection in Base class by using define_method for options - Consolidate version options handling and improve initialization - Replace strict? method calls with direct strict access - Fix parameter_key references to use parameter method directly - Improve version matching logic and error handling consistency
- Replace route_setting calls with direct inheritable_setting.route access - Update desc.rb to use inheritable_setting.route[:description] - Update inside_route.rb to use inheritable_setting.route for renamed_params and declared_params - Update routing.rb to use inheritable_setting.route[:description] and fix method handling - Update endpoint.rb to use inheritable_setting.route for declared_params and saved_validations - Update params_scope.rb to use inheritable_setting.route[:renamed_params] - Update tests to use proper inheritable_setting structure
c2c0887 to
a8b9a8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor route_setting internal usage to use inheritable_setting.route
Summary
This PR refactors the internal usage of
route_settingmethod calls to directly useinheritable_setting.routehash access. This change improves code consistency and removes the need for the intermediateroute_settingmethod in internal Grape code.Changes Made
Core Library Changes
lib/grape/dsl/desc.rb: Replacedroute_setting(:description, settings)withinheritable_setting.route[:description] = settingslib/grape/dsl/inside_route.rb:route_setting(:renamed_params)withinheritable_setting.route[:renamed_params]route_setting(:declared_params)withinheritable_setting.route[:declared_params]lib/grape/dsl/routing.rb:route_setting(:description)withinheritable_setting.route[:description]:anyroutes (changedmethodstomethod)lib/grape/endpoint.rb:route_setting(:declared_params, ...)withinheritable_setting.route[:declared_params] = ...route_setting(:saved_validations, ...)withinheritable_setting.route[:saved_validations] = ...validationsmethod to use direct hash accesslib/grape/validations/params_scope.rb:route_setting(:renamed_params)withinheritable_setting.route[:renamed_params]Test Updates
spec/grape/dsl/desc_spec.rb: Simplified test class by extendingGrape::DSL::Settingsinstead of manually implementing route_setting methodsspec/grape/dsl/routing_spec.rb: Updated test expectations to useinheritable_setting.routestructureBenefits
Breaking Changes
None. This is an internal refactoring that doesn't change the public API.
Testing
Files Changed
lib/grape/dsl/desc.rblib/grape/dsl/inside_route.rblib/grape/dsl/routing.rblib/grape/endpoint.rblib/grape/validations/params_scope.rbspec/grape/dsl/desc_spec.rbspec/grape/dsl/routing_spec.rbRelated Issues
This refactoring is part of improving the internal architecture of Grape's route setting management system.