-
Notifications
You must be signed in to change notification settings - Fork 14
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
allow memoize
to take multiple method names
#37
allow memoize
to take multiple method names
#37
Conversation
This mimics the interface Memoist allowed, without any real cost, and allows Memery to be more of a drop-in replacement
No interest, @tycooon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, looks like I missed this PR somehow.
It also looks like you have some uncovered code in the specs. |
Hmm. I didn't originally, maybe the specs I just removed did matter :-\ Edit: Oh! uncovered spec lines, I see :-) |
I am ready to merge, but rubocop is not happy with empty block (and I agree with that). |
hmm, that's interesting. I ran rubocop locally, but apparently that doesn't execute the same checks your CI is performing. That's awkward - I can't define a method with an empty body, but if I put anything in the body, it'll show up as non-executed code for your coverage system :-\ Ah, I'll define those methods via |
this is a way to satisfy the coverage and linters at the same time - we can't define a method with an empty block, but we aren't _calling_ those methods, so if we put any actual lines of code inside they'll end up failing the coverage check
Thanks for your attention! I'll look forward to deleting one of the many monkey-patches I've had to make updating to ruby3 :-) |
Purpose
I'm performing the upgrade to ruby-3 on a large rails project, and we used Memoist heavily. Memoist hasn't updated to support memoizing with keyword arguments in ruby 3 yet, and it looks like it might be quite difficult to do so - there have been outstanding tickets for roughly that feature for years now.
Swapping Memery in instead has been mostly seamless, but its lack of support for
memoize :foo, :bar, :baz
is forcing updates to several hundred files (some of our engineers dislikedmemoize def foo
, because they felt it was too "java-ey").Original Internal Patch
I initially just wrote a prepend-patch for my own project to support it:
And I'm happy to continue to use that.. but I figured I'd check if you were interested in adopting the change upstream.
Specs
The code change is fairly trivial, but I didn't feel like the existing test-suite structure made it easy to exercise the change - let me know if you have a preference for test structure here I should update to match (or feel free to take the PR and just rewrite it as you prefer. I have the time, but I know communication is frequently more work than coding).