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

Fix for Ruby 3 keyword arg splatting change #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jasonperrone
Copy link

This is how I addressed the Ruby 3 keyword args splatting change incompatibility as mentioned here: https://bugs.ruby-lang.org/issues/14183.

Tests pass. Up to you if you want to accept this change.

reload = Memoist.extract_reload!(method(#{unmemoized_method.inspect}), args)

skip_cache = reload || !(instance_variable_defined?(#{memoized_ivar.inspect}) && #{memoized_ivar} && #{memoized_ivar}.has_key?(args))
skip_cache = reload || !(instance_variable_defined?(#{memoized_ivar.inspect}) && #{memoized_ivar} && #{memoized_ivar}.has_key?(args+kwargs.values))

Choose a reason for hiding this comment

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

ignoring of kwargs.keys is not quite accurate, this way we make no difference between account(local: true) and account(remote: true)

Copy link
Author

Choose a reason for hiding this comment

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

True. Appreciate any help.

Choose a reason for hiding this comment

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

what about using kwargs.to_a?

Choose a reason for hiding this comment

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

we simply use cache_key = args + [kwargs] at the moment )

@stokarenko
Copy link

Hey @sebjacobs, is there any chance to get it released? I'm ready to improve this PR a bit as per my comment above )

@pboling
Copy link
Contributor

pboling commented Mar 11, 2022

ping! I am starting to use this on a Ruby 3 project now. Until this is fixed I'll only be able to use memoist on methods without arguments

@patbl
Copy link

patbl commented Jun 5, 2022

@pboling #88 (comment)

@pboling
Copy link
Contributor

pboling commented Jun 4, 2024

FYI: Added this alert to the new memoist repo

Important

Recommendation

Consider using MemoWise instead, as it is maintained, fully tested, provides thread safety guarantees, and is much, much faster.

Other Alternatives

In case you need a tool with this feature set that is currently maintained, check out:

Tip

Seriously though, read the important note above.

Warning

If you must continue - be aware that this is unmaintained software.

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.

5 participants