We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I see there was some discussion about this issue in #49 , but it seems the validations did not make it into the master branch.
# job.rb class Job < ApplicationRecord enum :status, {pending: 0, running: 1, done: 2, cancelled: 3} do event :run do transition [:pending] => :running end event :cancel do transition [:pending, :running] => :cancelled end event :finish do transition [:running] => :done end end end
irb(main):001> job = Job.create! => #<Job:0x0000000107822e60 id: 1, status: "pending", created_at: Sun, 22 Sep 2024 15:35:34.179823000 UTC +00:00, updated_at: Sun, 22 Sep 2024 15:35:34.179823000 UTC +00:00> irb(main):002> job.run! => true irb(main):003> job.status => "running" irb(main):004> job.finish! => true irb(main):005> job.status => "done" irb(main):006> job.cancel! GEMPATH/stateful_enum-0.7.0/lib/stateful_enum/machine.rb:71:in `block (2 levels) in initialize': Invalid transition (RuntimeError) irb(main):007> job.update status: :cancelled => true irb(main):008> job.status => "cancelled"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I see there was some discussion about this issue in #49 , but it seems the validations did not make it into the master branch.
The text was updated successfully, but these errors were encountered: