ryanza/stateflow — pull request #40 by jamesotron (2013-08-07 22:16:12+00:00)
Title: Allow events to define a transition_missing hook.

I've added a `transition_missing` hook so that events can implement
their own logic for dealing with events received in an improper state.

For example:

```ruby
class Order
stateflow do
initial :received
state :received,:paid,:shipped,:cancelled

event :payment_received do
transitions from: :received, to: :paid
end

event :shipment_sent do
transitions from: :paid, to: :shipped
end

event :cancel do
transitions from: :received, to: :cancelled
transitions from: :paid, to: :cancelled

transition_missing do |from_state|
if from_state == 'shipped'
raise "Can't cancel a shipped order."
end
end
end
end
end
```

This allows a user to define their own Exception to be raised, or,
in fact any logic (like send another event to move into an error state).