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

Don't cache Class.instance_methods #2328

Merged
merged 1 commit into from
May 19, 2023

Conversation

casperisfine
Copy link

Fix: #2258

Some gems or app code may define methods on Class after grape is loaaded but before override_all_methods! is called.

As such it's better to check Class.method_defined? when doing the override.

@dblock
Copy link
Member

dblock commented May 16, 2023

Care to add a test for this? Could be an integration test that adds a method to Class so it doesn't pollute other tests. You'll also need to update CHANGELOG. Thanks!

@casperisfine
Copy link
Author

Done.

@dblock
Copy link
Member

dblock commented May 17, 2023

Test looks good. CHANGELOG needed, danger is about to complain.

@casperisfine casperisfine force-pushed the class-dymanic-methods branch 2 times, most recently from b5c6f79 to 432d36c Compare May 18, 2023 08:20
@casperisfine
Copy link
Author

Done.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Danger is nitpicky, sorry :)

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
dblock

This comment was marked as duplicate.

dblock

This comment was marked as duplicate.

dblock

This comment was marked as duplicate.

@casperisfine
Copy link
Author

Done.

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@

#### Fixes

* [#2328](https://github.com/ruby-grape/grape/pull/2328): Don't cache Class.instance_methods - [@byroot](https://github.com/byroot).
Copy link
Member

@dblock dblock May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 there's an extra space in front of *

SORRY, we'll get there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, that's on me for doing these silly mistakes.

Fix: ruby-grape#2258

Some gems or app code may define methods on `Class` after `grape` is
loaaded but before `override_all_methods!` is called.

As such it's better to check `Class.method_defined?` when doing the override.
@casperisfine
Copy link
Author

Done.

@dblock dblock merged commit cc285a3 into ruby-grape:master May 19, 2023
23 checks passed
@dblock
Copy link
Member

dblock commented May 19, 2023

Merged, thanks for hanging in here with me!

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.

Uninitialized constant error for nested class of Grape::API class when using bootsnap and sidekiqswarm
3 participants