jdleesmiller/event_state — pull request #2 by nessche (2013-02-20 12:57:40+00:00)
Title: Split DSL/State machine functionality from Connection-dependent aspects

Hi,

in my project I needed to have an EM-aware state machine inside a process where EM is already running. The state machine, though, it is not facing the outer world, but is used to represent the state of the whole server.
So I needed to split the part related to EM::Connection from the DSL and state handling part, which is what the commits in this pull request do:

* I splitted the code in `machine.rb` into two: the `EM::Connection` part stayed in the file, while the DSL and state handling went into the `SimpleMachine` module which is then included by the `Machine` class. This way the changes are 100% backwards compatible as the result `Machine` class has no more or no less than before.
* I added a `HookableMachine` class which also includes `SimpleMachine` but relies on a callback object to send the messages wherever they need to go.
* I added a test for the `HookableMachine` and an example implementation of the callback handler.

Older tests continue to work, I added also some documentation in the source files, but did not touch the README file.

Tested on 1.8.7-p371, 1.9.2-p320 and 1.9.3-p385.