README.md in end_state-0.1.0 vs README.md in end_state-0.2.0

- old
+ new

@@ -75,12 +75,17 @@ Optionally you can implement the `passed` and/or `failed` methods which will be called after the guard passes or fails. These will only be called during the check performed during the transition and will not be fired when asking `can_transition?`. These hooks can be useful for things like logging. The wrapped object has an array `failure_messages` available for tracking reasons for invalid transitions. You may shovel -a reason (string) into this if you want to provide information on why your guard failed. +a reason (string) into this if you want to provide information on why your guard failed. You can also use the helper method in +the `Guard` class called `add_error` which takes a string. +The wrapped object has an array `success_messages` available for tracking reasons for valid transitions. You may shovel +a reason (string) into this if you want to provide information on why your guard passed. You can also use the helper method in +the `Guard` class called `add_success` which takes a string. + ```ruby class EasyGuard < EndState::Guard def will_allow? true end @@ -119,12 +124,17 @@ * `object` - The wrapped object that has been rolled back. * `state` - The attempted desired state. * `params` - A hash of params passed when calling transition on the machine. The wrapped object has an array `failure_messages` available for tracking reasons for invalid transitions. You may shovel -a reason (string) into this if you want to provide information on why your finalizer failed. +a reason (string) into this if you want to provide information on why your finalizer failed. You can also use the helper method in +the `Finalizer` class called `add_error` which takes a string. +The wrapped object has an array `success_messages` available for tracking reasons for valid transitions. You may shovel +a reason (string) into this if you want to provide information on why your finalizer succeeded. You can also use the helper method in +the `Finalizer` class called `add_success` which takes a string. + ```ruby class WrapUp < EndState::Finalizer def call # Some important processing true @@ -192,9 +202,15 @@ All other failures, such as missing transition, guard failure, or finalizer failure will silently just return `false` and not transition to the new state. You also have the option to use `transition!` which will instead raise an error for failures. If your guards and/or finalizers add to the `failure_messages` array then they will be included in the error message. + +## Graphing + +If you install `GraphViz` and the gem `ruby-graphviz` you can create images representing your state machines. + +`EndState::Graph.new(MyMachine).draw.output png: 'my_machine.png'` ## Testing Included is a custom RSpec matcher for testing your machines.