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

Method to determine if an event is allowed #25

Open
cgriego opened this issue Oct 14, 2011 · 1 comment
Open

Method to determine if an event is allowed #25

cgriego opened this issue Oct 14, 2011 · 1 comment
Assignees

Comments

@cgriego
Copy link

cgriego commented Oct 14, 2011

To support user input validation logic I'm writing, I need the ability to ask a model if it will allow an event to transition. If the event were name "close" then something like "can_close?". Without a method, I've had to reach deep into the internals of stateflow from my model.

  def can_close?
    self.class.machine.events[:close].send(:transitions).select do |transition|
      transition.from.include? current_state.try(:name)
    end.first.try(:can_transition?, self)
  end
@ryanza
Copy link
Owner

ryanza commented Oct 18, 2011

Cool idea, I'll get onto it!

@ghost ghost assigned ryanza Oct 18, 2011
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

2 participants