Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegates calls to inner object is some classes by extends Forwardable #2535

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

ericproulx
Copy link
Contributor

@ericproulx ericproulx commented Feb 16, 2025

This PR will delegate some functions to some inner objects. Here are the details:

api.rb

Add delegation to base_instance and instance_for_rack
Use delegate_missing_to instead of method_missing functions

endpoint.rb

Delegate params and headers to request
Remove LazyObject for build_headers since its not forced

request.rb

Use each_header from Rack::Request instead of env.each_pair
Remove .to_s since Ruby 2.7 added start_with? to symbols

stack.rb

Delegates some functions

… instance_for_rack

Use `delegate_missing_to` instead of method_missing

Add forwardable in endpoint.rb.
Delegate `params` and `headers` to `request`
Remove LazyObject for build_headers since its not forced in endpoint.rb anymore.

Small refactor to request.rb
Use `each_header` from Rack::Request instead of `env.each_pair`
Remove `.to_s` since Ruby 2.7 added `start_with?` to symbols

Add forwardable in stack.rb.
@ericproulx ericproulx marked this pull request as ready for review February 16, 2025 13:07
@grape-bot
Copy link

grape-bot commented Feb 16, 2025

1 Warning
⚠️ There're library changes, but not tests. That's OK as long as you're refactoring existing code.

Generated by 🚫 Danger

@ericproulx ericproulx requested a review from dblock February 16, 2025 13:08
@dblock dblock merged commit 6dfb610 into ruby-grape:master Feb 18, 2025
63 checks passed
@dblock
Copy link
Member

dblock commented Feb 18, 2025

LGTM, YOLO

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.

3 participants