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_setting
method calls to directly useinheritable_setting.route
hash access. This change improves code consistency and removes the need for the intermediateroute_setting
method in internal Grape code.Changes Made
Core Library Changes
lib/grape/dsl/desc.rb
: Replacedroute_setting(:description, settings)
withinheritable_setting.route[:description] = settings
lib/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]
:any
routes (changedmethods
tomethod
)lib/grape/endpoint.rb
:route_setting(:declared_params, ...)
withinheritable_setting.route[:declared_params] = ...
route_setting(:saved_validations, ...)
withinheritable_setting.route[:saved_validations] = ...
validations
method 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::Settings
instead of manually implementing route_setting methodsspec/grape/dsl/routing_spec.rb
: Updated test expectations to useinheritable_setting.route
structureBenefits
Breaking Changes
None. This is an internal refactoring that doesn't change the public API.
Testing
Files Changed
lib/grape/dsl/desc.rb
lib/grape/dsl/inside_route.rb
lib/grape/dsl/routing.rb
lib/grape/endpoint.rb
lib/grape/validations/params_scope.rb
spec/grape/dsl/desc_spec.rb
spec/grape/dsl/routing_spec.rb
Related Issues
This refactoring is part of improving the internal architecture of Grape's route setting management system.