-
Notifications
You must be signed in to change notification settings - Fork 899
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 class: Reifier #583
Conversation
Yea, I will agree that the code base as a whole could definitely stand some refactoring into smaller modules and methods of less length, I've certainly allowed some of the methods to become unwieldy over time (not that I can remember it ever being super great in that regard). Do you think it makes more sense to have this |
I'd prefer to not mix
Also, I think this class is easier to understand if it stands alone. It's still tightly coupled to ActiveRecord (a lot of AR methods are called) but they are all called with explicit receiver, so the coupling is more obvious.
I don't think so, not the way it's currently written. Are you concerned about memory usage? I could do some profiling fairly easily. |
Mind if I merge this, Ben? |
Apologies for the delayed review, I've been on vacation. I'll take a closer look this afternoon. |
add9cb3
to
2b2079a
Compare
module PaperTrail | ||
|
||
# Given a version record and some options, builds a new model object. | ||
# @api private |
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.
What does this comment mean?
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.
@api private
indicates a private part of a library's API.
I've seen it, and its inverse @api public
, used in major ruby libraries like rspec (https://github.com/rspec/rspec-expectations/blob/14faeab88f319ac0c2e4d793ec02c2b69eb52a5c/lib/rspec/matchers/composable.rb#L9). I think it comes from javadoc originally.
Thanks. Don't rush your review (it's a big change!) but there is going to be a conflict with #596 so it would be great if I didn't have to rebase this too many times. Git conflicts aren't a big deal, but let's not let this get stale if it is something you're interested in. Thanks. |
d729b29
to
7377b6d
Compare
Ben, this is ready for another review. I've changed it from a class to a module as we discussed and I've rebased, resolving the conflict with #596 |
This refactoring encapsulates the process of reification, separating it from the model (VersionConcern). The ABC complexity score of VersionConcern (measured by flog) is reduced from 750 to 362, a 52% reduction. Finally, this refactoring provides a truely private namespace for methods like `reify_has_many_through`. Such methods will no longer be mixed into PaperTrail::Version, or end-user's version models, if any.
7377b6d
to
fbac7a6
Compare
Mind if I merge this? I'm getting a little antsy because I had to fix another conflict today, sorry. |
Sorry Jared, was away on a trip with limited access to internet for the last 5 days. This looks good to me, and it is aligned with what we discussed during our conversation. 👍 |
Extract functionality to module: Reifier
No worries, thanks for the review, I know it was a big one! |
This refactoring encapsulates the process of reification, separating
it from the model (VersionConcern).
The ABC complexity score of VersionConcern (measured by flog) is
reduced from 750 to 362, a 52% reduction.
Finally, this refactoring provides a truely private namespace for
methods like
reify_has_many_through
. Such methods will nolonger be mixed into PaperTrail::Version, or end-user's version
models, if any.