Coder Social home page Coder Social logo

Comments (5)

troessner avatar troessner commented on June 21, 2024

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..:-)

from transitions.

troessner avatar troessner commented on June 21, 2024

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

from transitions.

dlepage avatar dlepage commented on June 21, 2024

Sure ! :) First of all, most of the time it's better to split a model into simple models... but sometime, it's overkill.

We can imagine a model that you have two(or more) points of view... eg. :

  • Human... mental_state, physical_state...
  • Order : shipping(processing) state, invoice state (NOTE: I know, an Invoice model can do the trick but adding a model just to manage a state seems overkill (and more left joins is not really better...)).

On 2012-05-18, at 07:16, Timo Rößner wrote:

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


Reply to this email directly or view it on GitHub:
#50 (comment)

from transitions.

troessner avatar troessner commented on June 21, 2024

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.

from transitions.

dlepage avatar dlepage commented on June 21, 2024

Please add "this gem is limited to one state machine for each model.

Envoyé de mon iPhone

Le 2012-05-21 à 18:41, "Timo Rößner"
[email protected]
a écrit :

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.


Reply to this email directly or view it on GitHub:
#50 (comment)

from transitions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.