Revert PR #2577: Restore support for return in endpoint blocks
#2641
+14
−23
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.
Revert PR #2577: Restore support for
returnin endpoint blocksSummary
This PR reverts the changes introduced in PR #2577 that deprecated the use of
returnin endpoint blocks and simplified endpoint block execution. Based on the discussion in PR #2577, we are restoring the previous behavior that allowsreturnstatements to work without deprecation warnings.Background
PR #2577 ("Simplify endpoint block execution and deprecate
returncall in it") changed how endpoint blocks are executed by:instance_execinstead of converting blocks to unbound methodsLocalJumpErrorexceptions and issuing deprecation warnings whenreturnwas usednextinstead ofreturnAfter further discussion, it was decided to revert these changes to maintain backward compatibility and restore the original behavior.
Changes
Endpoint Block Execution (
lib/grape/endpoint.rb)block_to_unbound_methodclass method: Converts blocks to unbound methods for properreturnhandlinginstance_exec(&@source)back to@source.bind_call(self)LocalJumpErrorrescue block that issued deprecation warnings forreturnstatementsTests (
spec/grape/endpoint_spec.rb)returntest: Removed deprecation warning expectationsnexttest: No longer needed sincereturnis the supported approach againImpact
returnstatements in endpoint blocks now work without deprecation warningsreturnreturncall in it #2577Related
returncall in it