Refactor route_setting internal usage to use inheritable_setting.route #2601
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.