Skip to content
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

List all possible states an object can have #33

Closed
troessner opened this issue Aug 23, 2011 · 12 comments
Closed

List all possible states an object can have #33

troessner opened this issue Aug 23, 2011 · 12 comments

Comments

@troessner
Copy link
Owner

Concrete use case:

Admin interface: List all possible state names an object can have.

Right now this is only possible like this:

Order.state_machines.first[1].states.map(&:name)

which is obscure and counter intuitive.

We need something which is intuitive and easily accessible a la:

Order.possible_states

which the first state machine being the default argument or something like that.

I'll look into this as soon as possible.

@qoobaa
Copy link
Collaborator

qoobaa commented Aug 24, 2011

Seems good. Is there a possibility to have multiple machines in the same model? If there is, you need to provide multiple "possible_states" methods.

BTW: add yourself to README/LICENSE files. You're the current maintainer of the gem, aren't you? You can also move the repository to your github account if you wish.

@troessner
Copy link
Owner Author

Seems good. Is there a possibility to have multiple machines in the same model? If there is, you need to provide multiple "possible_states" methods.

-> Ack.

You can also move the repository to your github account if you wish.

You're right, this would make sense, will do so later.

@troessner
Copy link
Owner Author

@qoobaa you would need to transfer ownership for this repository to my account since I can't do that myself, then I'll update licence, contact details etc.

@qoobaa
Copy link
Collaborator

qoobaa commented Aug 24, 2011

To transfer this repo to another user, please contact support. 

I'll do it later. You can always create a fork or something.

@troessner
Copy link
Owner Author

I'll do it later.

Great, thanks!

@elskwid
Copy link

elskwid commented Aug 30, 2011

@troessner, I have a module I use that does something similar:

def state_names
  state_machines[:default].states.map(&:name)
end

I have been thinking about the multiple state machines per model/class. Currently, the ActiveRecord Module would break under these circumstances as it only ever writes to a field named :state - I've got some thoughts on this, perhaps a new issue?

@troessner
Copy link
Owner Author

@elskwid

Currently, the ActiveRecord Module would break under these circumstances as it only ever writes to a field named :state

Very good point.

I've got some thoughts on this, perhaps a new issue?

Yes, please create a new issue.

Actually, I can't think of a "real life" use case for multiple state machines.
If one really needs multiple state machines for one model this seems like a strong indicator that he actually needs two different models, not two different state machines.

@qoobaa
Copy link
Collaborator

qoobaa commented Aug 31, 2011

If one really needs multiple state machines for one model this seems like a strong indicator that he actually needs two different models, not two different state machines.

Take a look at https://github.com/qoobaa/pioneers/blob/master/app/models/game.rb and try to merge those machines, or create a separate model :-).

@troessner
Copy link
Owner Author

@qoobaa hmm, I see. Well, at least now I know a real life example...:-)

@qoobaa
Copy link
Collaborator

qoobaa commented Oct 12, 2011

From: Petros Amiridis (GitHub Staff)
Subject: [Contact] Transfer repo: qoobaa/transitions

I am afraid troessner/transitions already exists

Can you delete your fork? Then I'll try to transfer the repo again.

@troessner
Copy link
Owner Author

Done...:-)

@troessner
Copy link
Owner Author

3c5cb9d
-> Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants