-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Extract caching into its own module. #1402
Conversation
c4f6baf
to
f9495e2
Compare
module ClassMethods | ||
def inherited(base) | ||
super | ||
caller_line = caller.second |
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.
Note that now that caching is inside a mixin, the actual serializer definition is in the second position in the call stack.
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.
Could still be the below, right?
def inherited(base)
caller_line = caller.first
super
base._cache_digest = digest_caller_file(caller_line)
end
Also, I'd rather use caller[1]
than second just because I prefer to avoid core extensions. I'm not sure if you have a preference.
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.
though, we should probably rename the local var to serializer_source_location
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.
Nope, the Caching#inherited
method is always called from Serializer#inherited
. I did make the change to caller[1]
though.
f9495e2
to
38c461c
Compare
💯 I'm not big on the extra-a-module pattern, but I really think this helps us better understand the parts of the serializer public api. Interestingly, there was once a Serializer::DSL object, but it was only in the refactor branch. |
I'm ok to merge this once tests pass |
38c461c
to
26367d3
Compare
26367d3
to
fd06a8a
Compare
Tests passed, I'm merging as @bf4 agreed. |
Extract caching into its own module
No description provided.