-
Notifications
You must be signed in to change notification settings - Fork 163
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
Cleaner ActiveRecordQueries mixin #358
Cleaner ActiveRecordQueries mixin #358
Conversation
I like this, and think the advantages you list are pretty compelling. I'm not going to be able to properly review this now- grabbing a flight to Thailand for 2 weeks tomorrow morning!- but wanted to drop an early favourable opinion before I vanish, in case anyone reviews it in my absence. |
Pass configuration to the mixin as arguments, and only define the three documented public methods, moving the other private methods into a separate, inaccessible object.
760313a
to
d42d568
Compare
@lawrencejones I've rebased, and you're back from 🇹🇭. Wanna get this merged? 😄 |
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.
Code looks ok, though not sure that I find the benefits meaningful.
Releasing with a Major bump makes most sense to me given it can break existing code.
end | ||
|
||
def states_where(states) | ||
if initial_state.to_s.in?(states.map(&:to_s)) |
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.
You can remove .map(&:to_s)
here since you know the define_
methods above have already done that.
Looks like @isaacseymour might be busy now- going to leave that cleanup of |
Pass configuration to the mixin as arguments, and only define the three
documented public methods, moving the other private methods into a
separate, inaccessible object.
The advantage of this is:
Disadvantages are:
has_many
- which is kinda icky style-wise (and potentially a breaking change)? Could argue that instead we should have an interface like(although that adds another indirection which hides the
include
more)In the README I've defined this as a minor-level change because the old-style will still work. I think this is probably wrong now I'm writing about it, given that the check for the definition of the
transition_class
andinitial_state
class methods now runs when it's included, so if you hadit'll break.
Can either:
in_state
runsInterested to hear thoughts from @lawrencejones and whoever else is maintaining this these days 😄