tablexi / flow_machine Goto Github PK
View Code? Open in Web Editor NEWBuild finite state machines in a backend-agnostic, class-centric way.
License: MIT License
Build finite state machines in a backend-agnostic, class-centric way.
License: MIT License
Currently, if we call an event on the workflow object that doesn't exists in the current state, we get a no-op false
return value rather than a NotMethodError
or something similar. Could it be more handy for the development environment to raise an exception here to help track down bad code paths (a caller that is trying to do a wrong transition on a specific scenario) instead? Even if the client code checks for falsy
return values there is no way to know that an invalid transition/event was called.
Here is a piece of code to illustrate the scenario:
class PublishingWorkflow
include FlowMachine::Workflow
state DraftState
state PublishedState
end
class DraftState < FlowMachine::WorkflowState
event :publish do
transition to: :published
end
end
class PublishedState < FlowMachine::WorkflowState
event :retract do
transition to: :retracted
end
end
workflow = PublishingWorkflow.new(BlogPost.new(state: :draft))
# drafts can't be retracted.
workflow.retract! #=> false
It's sometimes handy to add the scopes as: FlowMachine::Workflow.class_for(self).create_scopes_on(self)
, but that is very verbose.
Proposal: FlowMachine::Workflow.create_scopes_on(self)
which calls class_for
Add RDoc documentation
When config.warnings = true
in spec_helper
is enabled, there are several warnings about uninialized instance variables.
flow_machine/lib/flow_machine/workflow.rb:67: warning: instance variable @state_attribute not initialized
flow_machine/lib/flow_machine/workflow.rb:162: warning: instance variable @previous_state not initialized
Deprecate the methods in FlowMachine::Factory
in favor of having them straight on FlowMachine
Example:
Previous: FlowMachine::Factory.workflow_for(...)
New: FlowMachine.workflow_for(...)
And add notes about these methods to the README.
Currently, there are a few places where we are using ActiveSupport: try
, delegate
, Inflectors, and extract_options!
. Ideally these would not be used.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.