-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add prefix functionality to scopes to facilitate multiple state machines on one model. #14
Conversation
README.md
Outdated
# ... | ||
end | ||
|
||
steady_state :temperature, scopes: true, scopes_prefix: 'temperature' do |
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.
steady_state :temperature, scopes: true, scopes_prefix: 'temperature' do | |
steady_state :temperature, scopes: { prefix: true } do |
I might propose this style (similar to Rails' delegate
prefix option), where prefix: true
would default to the name of the state field, and prefix: 'something_else'
would allow you to override it with something else.
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.
(Otherwise, I love the idea -- Going to wait to review the underlying implementation until the API is settled -- LMK when it's ready for review!)
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.
Great! And also, I really like the idea to make it like rails delegate.. When Ray and I were talking about this, he also thought about prefix: true
but we didn't make the connection to do it all three ways. I will update the PR and write a description shortly!
381c15a
to
aca198d
Compare
aca198d
to
a7b1146
Compare
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.
domain LGTM
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.
platform TAFN -- just the one note! Mostly a thought about how to get an ArgumentError
idiomatically, but overall, this looks great.
Before you merge, you may also want to bump the version number so that I can cut you a release right away. (Not that you need this urgently or anything... apologies for the slow review. 😅)
Will also bump version number! No apologies necessary! |
Invalidated by push of cefff29
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.
domain LGTM && platform LGTM!
Looks like a dependabot merge may have messed up the build matrix gemfiles. You can run bundle exec appraisal install
to regenerate those, or we can do that in a separate PR.
@nicholalexander fixed the build issue over here: |
add a test for a custom and true prefix. update documentation to demonstrate all usages.
Update readme to make demonstrate new api.
Co-authored-by: Nathan Griffith <[email protected]>
58c0845
to
89f1535
Compare
@@ -1,5 +1,5 @@ | |||
# frozen_string_literal: true | |||
|
|||
module SteadyState | |||
VERSION = '1.1.0' | |||
VERSION = '1.2.0' |
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.
I think you'll need to re-run bundle install
and bundle exec appraisal install
(and bundle exec rubocop -A
if appraisal introduces linter errors, lol), and then commit those changes. That should be the last piece of this that will unblock your build.
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.
Thanks! I started on this yesterday and got sidetracked - should be incoming!
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.
domain LGTM && platform LGTM!
When using multiple state machines on a single model, one might want more control over their scopes. In order to allow that, this PR adds handling a hash with some prefix options that works similar to how delegate in rails works. You can pass in
scopes: { prefix: true }
to get your scope prefixed with your attribute orscopes: { prefix: 'some_custom_prefix' }
to get your scope prefixed with a custom prefix.This PR also adds associated tests and updates the Readme.