Skip to content

Multiple state_machines... #50

Closed
dlepage opened this Issue May 16, 2012 · 5 comments

2 participants

@dlepage
dlepage commented May 16, 2012

Is it possible to have more than one state_machine in a model.

How to setup (state column name, fire évents from this second state_machine ?)

Many thanks !

@troessner
Owner

Well, in theory it should be possible, however I found out that this doesn't work right now unfortunately.
If I find the time, I'll fix that - of course pull requests are welcome..:-)
To be honest this isn't very high on my priority list, because whenever I had the need for two state machines, I basically wanted two different models. However I don't deny that there might be use cases where multiple state machines make sense, I just haven't encountered one.
As far as I can see even naming a state machine with

state_machine :foo do

breaks the functionality. But then again, naming a state machine only makes sense if we have more than one (otherwise it's just default), so this is all more or less the same issue.

I am thinking of something like this (This won't work right now):

state_machine do # name will be `default`
  ...
end

state_machine :foo
  ...
end

where you can switch like that

my_model.switch_state_machine :foo

If you need that badly, you'll have to come up with a pull request I'm afraid..:-)

@troessner
Owner

@dlepage Oh, and what's your use case for having multiple state machines for one model?

@dlepage
@troessner
Owner

I see your reasoning. However, I am not convinced - "Human being" would be a "human" object composed of "body" and "spirit" for me...:-)
I am closing this issue.

@troessner troessner closed this May 21, 2012
@dlepage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.