state_machine_deuxito 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +8 -0
  4. data/.yardopts +5 -0
  5. data/Appraisals +12 -0
  6. data/CHANGELOG.md +502 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +20 -0
  9. data/README.md +8 -0
  10. data/Rakefile +41 -0
  11. data/TODO.md +2 -0
  12. data/examples/AutoShop_state.png +0 -0
  13. data/examples/Car_state.png +0 -0
  14. data/examples/Gemfile +5 -0
  15. data/examples/Gemfile.lock +14 -0
  16. data/examples/TrafficLight_state.png +0 -0
  17. data/examples/Vehicle_state.png +0 -0
  18. data/examples/auto_shop.rb +13 -0
  19. data/examples/car.rb +21 -0
  20. data/examples/doc/AutoShop.html +2856 -0
  21. data/examples/doc/AutoShop_state.png +0 -0
  22. data/examples/doc/Car.html +919 -0
  23. data/examples/doc/Car_state.png +0 -0
  24. data/examples/doc/TrafficLight.html +2230 -0
  25. data/examples/doc/TrafficLight_state.png +0 -0
  26. data/examples/doc/Vehicle.html +7921 -0
  27. data/examples/doc/Vehicle_state.png +0 -0
  28. data/examples/doc/_index.html +136 -0
  29. data/examples/doc/class_list.html +47 -0
  30. data/examples/doc/css/common.css +1 -0
  31. data/examples/doc/css/full_list.css +55 -0
  32. data/examples/doc/css/style.css +322 -0
  33. data/examples/doc/file_list.html +46 -0
  34. data/examples/doc/frames.html +13 -0
  35. data/examples/doc/index.html +136 -0
  36. data/examples/doc/js/app.js +205 -0
  37. data/examples/doc/js/full_list.js +173 -0
  38. data/examples/doc/js/jquery.js +16 -0
  39. data/examples/doc/method_list.html +734 -0
  40. data/examples/doc/top-level-namespace.html +105 -0
  41. data/examples/merb-rest/controller.rb +51 -0
  42. data/examples/merb-rest/model.rb +28 -0
  43. data/examples/merb-rest/view_edit.html.erb +24 -0
  44. data/examples/merb-rest/view_index.html.erb +23 -0
  45. data/examples/merb-rest/view_new.html.erb +13 -0
  46. data/examples/merb-rest/view_show.html.erb +17 -0
  47. data/examples/rails-rest/controller.rb +43 -0
  48. data/examples/rails-rest/migration.rb +7 -0
  49. data/examples/rails-rest/model.rb +23 -0
  50. data/examples/rails-rest/view__form.html.erb +34 -0
  51. data/examples/rails-rest/view_edit.html.erb +6 -0
  52. data/examples/rails-rest/view_index.html.erb +25 -0
  53. data/examples/rails-rest/view_new.html.erb +5 -0
  54. data/examples/rails-rest/view_show.html.erb +19 -0
  55. data/examples/traffic_light.rb +9 -0
  56. data/examples/vehicle.rb +33 -0
  57. data/gemfiles/4.2.11.1.gemfile +9 -0
  58. data/gemfiles/4.2.11.1.gemfile.lock +57 -0
  59. data/gemfiles/active_model_3.0.0.gemfile +7 -0
  60. data/gemfiles/active_model_3.0.0.gemfile.lock +35 -0
  61. data/gemfiles/active_model_3.0.5.gemfile +7 -0
  62. data/gemfiles/active_model_3.0.5.gemfile.lock +35 -0
  63. data/gemfiles/active_model_3.1.1.gemfile +7 -0
  64. data/gemfiles/active_model_3.1.1.gemfile.lock +36 -0
  65. data/gemfiles/active_model_3.2.1.gemfile +7 -0
  66. data/gemfiles/active_model_3.2.12.gemfile +7 -0
  67. data/gemfiles/active_model_3.2.12.gemfile.lock +36 -0
  68. data/gemfiles/active_model_3.2.13.rc1.gemfile +7 -0
  69. data/gemfiles/active_model_3.2.13.rc1.gemfile.lock +36 -0
  70. data/gemfiles/active_model_4.0.0.gemfile +9 -0
  71. data/gemfiles/active_model_4.0.0.gemfile.lock +78 -0
  72. data/gemfiles/active_record_2.0.0.gemfile +9 -0
  73. data/gemfiles/active_record_2.0.0.gemfile.lock +39 -0
  74. data/gemfiles/active_record_2.0.5.gemfile +9 -0
  75. data/gemfiles/active_record_2.0.5.gemfile.lock +39 -0
  76. data/gemfiles/active_record_2.1.0.gemfile +9 -0
  77. data/gemfiles/active_record_2.1.0.gemfile.lock +39 -0
  78. data/gemfiles/active_record_2.1.2.gemfile +9 -0
  79. data/gemfiles/active_record_2.1.2.gemfile.lock +39 -0
  80. data/gemfiles/active_record_2.2.3.gemfile +9 -0
  81. data/gemfiles/active_record_2.2.3.gemfile.lock +39 -0
  82. data/gemfiles/active_record_2.3.12.gemfile +9 -0
  83. data/gemfiles/active_record_2.3.12.gemfile.lock +39 -0
  84. data/gemfiles/active_record_2.3.5.gemfile +9 -0
  85. data/gemfiles/active_record_2.3.5.gemfile.lock +39 -0
  86. data/gemfiles/active_record_3.0.0.gemfile +9 -0
  87. data/gemfiles/active_record_3.0.0.gemfile.lock +51 -0
  88. data/gemfiles/active_record_3.0.5.gemfile +9 -0
  89. data/gemfiles/active_record_3.0.5.gemfile.lock +50 -0
  90. data/gemfiles/active_record_3.1.1.gemfile +9 -0
  91. data/gemfiles/active_record_3.1.1.gemfile.lock +51 -0
  92. data/gemfiles/active_record_3.2.12.gemfile +9 -0
  93. data/gemfiles/active_record_3.2.12.gemfile.lock +51 -0
  94. data/gemfiles/active_record_3.2.13.rc1.gemfile +9 -0
  95. data/gemfiles/active_record_3.2.13.rc1.gemfile.lock +51 -0
  96. data/gemfiles/active_record_4.0.0.gemfile +11 -0
  97. data/gemfiles/active_record_4.0.0.gemfile.lock +83 -0
  98. data/gemfiles/data_mapper_0.10.2.gemfile +13 -0
  99. data/gemfiles/data_mapper_0.10.2.gemfile.lock +56 -0
  100. data/gemfiles/data_mapper_0.9.11.gemfile +13 -0
  101. data/gemfiles/data_mapper_0.9.11.gemfile.lock +71 -0
  102. data/gemfiles/data_mapper_0.9.4.gemfile +12 -0
  103. data/gemfiles/data_mapper_0.9.4.gemfile.lock +70 -0
  104. data/gemfiles/data_mapper_0.9.7.gemfile +13 -0
  105. data/gemfiles/data_mapper_0.9.7.gemfile.lock +67 -0
  106. data/gemfiles/data_mapper_1.0.0.gemfile +12 -0
  107. data/gemfiles/data_mapper_1.0.0.gemfile.lock +63 -0
  108. data/gemfiles/data_mapper_1.0.1.gemfile +12 -0
  109. data/gemfiles/data_mapper_1.0.1.gemfile.lock +63 -0
  110. data/gemfiles/data_mapper_1.0.2.gemfile +12 -0
  111. data/gemfiles/data_mapper_1.0.2.gemfile.lock +63 -0
  112. data/gemfiles/data_mapper_1.1.0.gemfile +12 -0
  113. data/gemfiles/data_mapper_1.1.0.gemfile.lock +61 -0
  114. data/gemfiles/data_mapper_1.2.0.gemfile +12 -0
  115. data/gemfiles/data_mapper_1.2.0.gemfile.lock +61 -0
  116. data/gemfiles/default.gemfile +5 -0
  117. data/gemfiles/default.gemfile.lock +30 -0
  118. data/gemfiles/graphviz_0.9.17.gemfile +7 -0
  119. data/gemfiles/graphviz_0.9.17.gemfile.lock +29 -0
  120. data/gemfiles/graphviz_0.9.21.gemfile +7 -0
  121. data/gemfiles/graphviz_0.9.21.gemfile.lock +29 -0
  122. data/gemfiles/graphviz_1.0.0.gemfile +7 -0
  123. data/gemfiles/graphviz_1.0.0.gemfile.lock +29 -0
  124. data/gemfiles/graphviz_1.0.3.gemfile +7 -0
  125. data/gemfiles/graphviz_1.0.3.gemfile.lock +29 -0
  126. data/gemfiles/graphviz_1.0.8.gemfile +7 -0
  127. data/gemfiles/graphviz_1.0.8.gemfile.lock +29 -0
  128. data/gemfiles/mongo_mapper_0.10.0.gemfile +8 -0
  129. data/gemfiles/mongo_mapper_0.10.0.gemfile.lock +47 -0
  130. data/gemfiles/mongo_mapper_0.11.2.gemfile +9 -0
  131. data/gemfiles/mongo_mapper_0.11.2.gemfile.lock +48 -0
  132. data/gemfiles/mongo_mapper_0.12.0.gemfile +9 -0
  133. data/gemfiles/mongo_mapper_0.12.0.gemfile.lock +48 -0
  134. data/gemfiles/mongo_mapper_0.5.5.gemfile +8 -0
  135. data/gemfiles/mongo_mapper_0.5.5.gemfile.lock +36 -0
  136. data/gemfiles/mongo_mapper_0.5.8.gemfile +8 -0
  137. data/gemfiles/mongo_mapper_0.5.8.gemfile.lock +36 -0
  138. data/gemfiles/mongo_mapper_0.6.0.gemfile +8 -0
  139. data/gemfiles/mongo_mapper_0.6.0.gemfile.lock +36 -0
  140. data/gemfiles/mongo_mapper_0.6.10.gemfile +8 -0
  141. data/gemfiles/mongo_mapper_0.6.10.gemfile.lock +36 -0
  142. data/gemfiles/mongo_mapper_0.7.0.gemfile +8 -0
  143. data/gemfiles/mongo_mapper_0.7.0.gemfile.lock +36 -0
  144. data/gemfiles/mongo_mapper_0.7.5.gemfile +8 -0
  145. data/gemfiles/mongo_mapper_0.7.5.gemfile.lock +39 -0
  146. data/gemfiles/mongo_mapper_0.8.0.gemfile +10 -0
  147. data/gemfiles/mongo_mapper_0.8.0.gemfile.lock +43 -0
  148. data/gemfiles/mongo_mapper_0.8.3.gemfile +10 -0
  149. data/gemfiles/mongo_mapper_0.8.3.gemfile.lock +43 -0
  150. data/gemfiles/mongo_mapper_0.8.4.gemfile +8 -0
  151. data/gemfiles/mongo_mapper_0.8.4.gemfile.lock +42 -0
  152. data/gemfiles/mongo_mapper_0.8.6.gemfile +8 -0
  153. data/gemfiles/mongo_mapper_0.8.6.gemfile.lock +42 -0
  154. data/gemfiles/mongo_mapper_0.9.0.gemfile +7 -0
  155. data/gemfiles/mongo_mapper_0.9.0.gemfile.lock +45 -0
  156. data/gemfiles/mongoid_2.0.0.gemfile +9 -0
  157. data/gemfiles/mongoid_2.0.0.gemfile.lock +49 -0
  158. data/gemfiles/mongoid_2.1.4.gemfile +9 -0
  159. data/gemfiles/mongoid_2.1.4.gemfile.lock +47 -0
  160. data/gemfiles/mongoid_2.2.4.gemfile +9 -0
  161. data/gemfiles/mongoid_2.2.4.gemfile.lock +47 -0
  162. data/gemfiles/mongoid_2.3.3.gemfile +9 -0
  163. data/gemfiles/mongoid_2.3.3.gemfile.lock +47 -0
  164. data/gemfiles/mongoid_2.4.0.gemfile +9 -0
  165. data/gemfiles/mongoid_2.4.0.gemfile.lock +47 -0
  166. data/gemfiles/mongoid_2.4.10.gemfile +9 -0
  167. data/gemfiles/mongoid_2.4.10.gemfile.lock +47 -0
  168. data/gemfiles/mongoid_2.5.2.gemfile +9 -0
  169. data/gemfiles/mongoid_2.5.2.gemfile.lock +47 -0
  170. data/gemfiles/mongoid_2.6.0.gemfile +9 -0
  171. data/gemfiles/mongoid_2.6.0.gemfile.lock +47 -0
  172. data/gemfiles/mongoid_3.0.0.gemfile +8 -0
  173. data/gemfiles/mongoid_3.0.0.gemfile.lock +45 -0
  174. data/gemfiles/mongoid_3.0.22.gemfile +8 -0
  175. data/gemfiles/mongoid_3.0.22.gemfile.lock +45 -0
  176. data/gemfiles/mongoid_3.1.0.gemfile +8 -0
  177. data/gemfiles/mongoid_3.1.0.gemfile.lock +45 -0
  178. data/gemfiles/sequel_2.11.0.gemfile +9 -0
  179. data/gemfiles/sequel_2.11.0.gemfile.lock +33 -0
  180. data/gemfiles/sequel_2.12.0.gemfile +9 -0
  181. data/gemfiles/sequel_2.12.0.gemfile.lock +33 -0
  182. data/gemfiles/sequel_2.8.0.gemfile +9 -0
  183. data/gemfiles/sequel_2.8.0.gemfile.lock +33 -0
  184. data/gemfiles/sequel_3.0.0.gemfile +9 -0
  185. data/gemfiles/sequel_3.0.0.gemfile.lock +33 -0
  186. data/gemfiles/sequel_3.10.0.gemfile +9 -0
  187. data/gemfiles/sequel_3.10.0.gemfile.lock +33 -0
  188. data/gemfiles/sequel_3.13.0.gemfile +9 -0
  189. data/gemfiles/sequel_3.13.0.gemfile.lock +33 -0
  190. data/gemfiles/sequel_3.14.0.gemfile +9 -0
  191. data/gemfiles/sequel_3.14.0.gemfile.lock +33 -0
  192. data/gemfiles/sequel_3.23.0.gemfile +9 -0
  193. data/gemfiles/sequel_3.23.0.gemfile.lock +33 -0
  194. data/gemfiles/sequel_3.24.0.gemfile +9 -0
  195. data/gemfiles/sequel_3.24.0.gemfile.lock +33 -0
  196. data/gemfiles/sequel_3.29.0.gemfile +9 -0
  197. data/gemfiles/sequel_3.29.0.gemfile.lock +33 -0
  198. data/gemfiles/sequel_3.34.0.gemfile +9 -0
  199. data/gemfiles/sequel_3.34.0.gemfile.lock +33 -0
  200. data/gemfiles/sequel_3.35.0.gemfile +9 -0
  201. data/gemfiles/sequel_3.35.0.gemfile.lock +33 -0
  202. data/gemfiles/sequel_3.4.0.gemfile +9 -0
  203. data/gemfiles/sequel_3.4.0.gemfile.lock +33 -0
  204. data/gemfiles/sequel_3.44.0.gemfile +9 -0
  205. data/gemfiles/sequel_3.44.0.gemfile.lock +33 -0
  206. data/init.rb +1 -0
  207. data/lib/state_machine.rb +8 -0
  208. data/lib/state_machine/assertions.rb +36 -0
  209. data/lib/state_machine/branch.rb +225 -0
  210. data/lib/state_machine/callback.rb +236 -0
  211. data/lib/state_machine/core.rb +12 -0
  212. data/lib/state_machine/core_ext.rb +2 -0
  213. data/lib/state_machine/core_ext/class/state_machine.rb +5 -0
  214. data/lib/state_machine/error.rb +13 -0
  215. data/lib/state_machine/eval_helpers.rb +87 -0
  216. data/lib/state_machine/event.rb +257 -0
  217. data/lib/state_machine/event_collection.rb +141 -0
  218. data/lib/state_machine/extensions.rb +149 -0
  219. data/lib/state_machine/graph.rb +92 -0
  220. data/lib/state_machine/helper_module.rb +17 -0
  221. data/lib/state_machine/initializers.rb +4 -0
  222. data/lib/state_machine/initializers/merb.rb +1 -0
  223. data/lib/state_machine/initializers/rails.rb +25 -0
  224. data/lib/state_machine/integrations.rb +121 -0
  225. data/lib/state_machine/integrations/active_model.rb +585 -0
  226. data/lib/state_machine/integrations/active_model/locale.rb +11 -0
  227. data/lib/state_machine/integrations/active_model/observer.rb +33 -0
  228. data/lib/state_machine/integrations/active_model/observer_update.rb +42 -0
  229. data/lib/state_machine/integrations/active_model/versions.rb +31 -0
  230. data/lib/state_machine/integrations/active_record.rb +552 -0
  231. data/lib/state_machine/integrations/active_record/locale.rb +20 -0
  232. data/lib/state_machine/integrations/active_record/versions.rb +123 -0
  233. data/lib/state_machine/integrations/base.rb +100 -0
  234. data/lib/state_machine/integrations/data_mapper.rb +511 -0
  235. data/lib/state_machine/integrations/data_mapper/observer.rb +210 -0
  236. data/lib/state_machine/integrations/data_mapper/versions.rb +85 -0
  237. data/lib/state_machine/integrations/mongo_mapper.rb +389 -0
  238. data/lib/state_machine/integrations/mongo_mapper/locale.rb +4 -0
  239. data/lib/state_machine/integrations/mongo_mapper/versions.rb +89 -0
  240. data/lib/state_machine/integrations/mongoid.rb +465 -0
  241. data/lib/state_machine/integrations/mongoid/locale.rb +4 -0
  242. data/lib/state_machine/integrations/mongoid/versions.rb +81 -0
  243. data/lib/state_machine/integrations/sequel.rb +486 -0
  244. data/lib/state_machine/integrations/sequel/versions.rb +95 -0
  245. data/lib/state_machine/machine.rb +2292 -0
  246. data/lib/state_machine/machine_collection.rb +86 -0
  247. data/lib/state_machine/macro_methods.rb +522 -0
  248. data/lib/state_machine/matcher.rb +123 -0
  249. data/lib/state_machine/matcher_helpers.rb +54 -0
  250. data/lib/state_machine/node_collection.rb +222 -0
  251. data/lib/state_machine/path.rb +120 -0
  252. data/lib/state_machine/path_collection.rb +90 -0
  253. data/lib/state_machine/state.rb +297 -0
  254. data/lib/state_machine/state_collection.rb +112 -0
  255. data/lib/state_machine/state_context.rb +138 -0
  256. data/lib/state_machine/transition.rb +470 -0
  257. data/lib/state_machine/transition_collection.rb +245 -0
  258. data/lib/state_machine/version.rb +3 -0
  259. data/lib/state_machine/yard.rb +8 -0
  260. data/lib/state_machine/yard/handlers.rb +12 -0
  261. data/lib/state_machine/yard/handlers/base.rb +32 -0
  262. data/lib/state_machine/yard/handlers/event.rb +25 -0
  263. data/lib/state_machine/yard/handlers/machine.rb +344 -0
  264. data/lib/state_machine/yard/handlers/state.rb +25 -0
  265. data/lib/state_machine/yard/handlers/transition.rb +47 -0
  266. data/lib/state_machine/yard/templates.rb +3 -0
  267. data/lib/state_machine/yard/templates/default/class/html/setup.rb +30 -0
  268. data/lib/state_machine/yard/templates/default/class/html/state_machines.erb +12 -0
  269. data/lib/tasks/state_machine.rake +1 -0
  270. data/lib/tasks/state_machine.rb +30 -0
  271. data/lib/yard-state_machine.rb +2 -0
  272. data/state_machine.gemspec +21 -0
  273. data/test/files/en.yml +17 -0
  274. data/test/files/switch.rb +15 -0
  275. data/test/functional/state_machine_test.rb +1067 -0
  276. data/test/test_helper.rb +8 -0
  277. data/test/unit/assertions_test.rb +40 -0
  278. data/test/unit/branch_test.rb +969 -0
  279. data/test/unit/callback_test.rb +704 -0
  280. data/test/unit/error_test.rb +43 -0
  281. data/test/unit/eval_helpers_test.rb +270 -0
  282. data/test/unit/event_collection_test.rb +398 -0
  283. data/test/unit/event_test.rb +1196 -0
  284. data/test/unit/graph_test.rb +98 -0
  285. data/test/unit/helper_module_test.rb +17 -0
  286. data/test/unit/integrations/active_model_test.rb +1245 -0
  287. data/test/unit/integrations/active_record_test.rb +2551 -0
  288. data/test/unit/integrations/base_test.rb +104 -0
  289. data/test/unit/integrations/data_mapper_test.rb +2194 -0
  290. data/test/unit/integrations/mongo_mapper_test.rb +2026 -0
  291. data/test/unit/integrations/mongoid_test.rb +2309 -0
  292. data/test/unit/integrations/sequel_test.rb +1896 -0
  293. data/test/unit/integrations_test.rb +83 -0
  294. data/test/unit/invalid_event_test.rb +20 -0
  295. data/test/unit/invalid_parallel_transition_test.rb +18 -0
  296. data/test/unit/invalid_transition_test.rb +115 -0
  297. data/test/unit/machine_collection_test.rb +603 -0
  298. data/test/unit/machine_test.rb +3431 -0
  299. data/test/unit/matcher_helpers_test.rb +37 -0
  300. data/test/unit/matcher_test.rb +155 -0
  301. data/test/unit/node_collection_test.rb +362 -0
  302. data/test/unit/path_collection_test.rb +266 -0
  303. data/test/unit/path_test.rb +485 -0
  304. data/test/unit/state_collection_test.rb +352 -0
  305. data/test/unit/state_context_test.rb +441 -0
  306. data/test/unit/state_machine_test.rb +31 -0
  307. data/test/unit/state_test.rb +1101 -0
  308. data/test/unit/transition_collection_test.rb +2168 -0
  309. data/test/unit/transition_test.rb +1558 -0
  310. metadata +451 -0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://www.rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2012 Aaron Pfeifer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # state_machine_deuxito
2
+
3
+ [![Build Status](https://secure.travis-ci.org/compwron/state_machine.png "Build Status")](http://travis-ci.org/pluginaweek/state_machine)
4
+ [![Gem](https://img.shields.io/gem/v/state_machine_deuxito.svg?style=flat)](http://rubygems.org/gems/state_machine_deuxito "View this project in Rubygems")
5
+ [![Gem Version](https://badge.fury.io/rb/state_machine_deuxito.svg)](https://badge.fury.io/rb/state_machine_deuxito)
6
+
7
+ This is a fork of https://github.com/seuros/state_machine for the use of https://github.com/doubleunion/arooo
8
+
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'rake'
6
+ require 'rake/testtask'
7
+
8
+ require 'appraisal'
9
+
10
+ desc 'Default: run all tests.'
11
+ task :default => :test
12
+
13
+ desc "Test state_machine."
14
+ Rake::TestTask.new(:test) do |t|
15
+ integration = %w(active_model active_record data_mapper mongoid mongo_mapper sequel).detect do |name|
16
+ Bundler.default_gemfile.to_s.include?(name)
17
+ end
18
+
19
+ t.libs << 'lib'
20
+ t.test_files = integration ? Dir["test/unit/integrations/#{integration}_test.rb"] : Dir['test/{functional,unit}/*_test.rb'] + ['test/unit/integrations/base_test.rb']
21
+ t.verbose = true
22
+ t.warning = true if ENV['WARNINGS']
23
+ end
24
+
25
+ namespace :appraisal do
26
+ desc "Run the given task for a particular integration's appraisals"
27
+ task :integration do
28
+ integration = ENV['INTEGRATION']
29
+
30
+ Appraisal::File.each do |appraisal|
31
+ if appraisal.name.include?(integration)
32
+ appraisal.install
33
+ Appraisal::Command.from_args(appraisal.gemfile_path).run
34
+ end
35
+ end
36
+
37
+ exit
38
+ end
39
+ end
40
+
41
+ load File.dirname(__FILE__) + '/lib/tasks/state_machine.rake'
data/TODO.md ADDED
@@ -0,0 +1,2 @@
1
+ 1. make a working travis build
2
+ 1. publish a gem version that can be used in doubleunion/arooo
Binary file
Binary file
data/examples/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://www.rubygems.org"
2
+
3
+ gem 'yard'
4
+ gem 'state_machine'
5
+ gem 'ruby-graphviz'
@@ -0,0 +1,14 @@
1
+ GEM
2
+ remote: http://www.rubygems.org/
3
+ specs:
4
+ ruby-graphviz (1.0.0)
5
+ state_machine (1.2.0)
6
+ yard (0.7.5)
7
+
8
+ PLATFORMS
9
+ ruby
10
+
11
+ DEPENDENCIES
12
+ ruby-graphviz
13
+ state_machine
14
+ yard
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ require 'state_machine'
2
+
3
+ class AutoShop
4
+ state_machine :initial => :available do
5
+ event :tow_vehicle do
6
+ transition :available => :busy
7
+ end
8
+
9
+ event :fix_vehicle do
10
+ transition :busy => :available
11
+ end
12
+ end
13
+ end
data/examples/car.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'state_machine'
2
+
3
+ class Car < Vehicle
4
+ state_machine do
5
+ event :reverse do
6
+ transition [:parked, :idling, :first_gear] => :backing_up
7
+ end
8
+
9
+ event :park do
10
+ transition :backing_up => :parked
11
+ end
12
+
13
+ event :idle do
14
+ transition :backing_up => :idling
15
+ end
16
+
17
+ event :shift_up do
18
+ transition :backing_up => :first_gear
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,2856 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: AutoShop
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="_index.html">Index (A)</a> &raquo;
37
+
38
+
39
+ <span class="title">AutoShop</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: AutoShop
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">AutoShop</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">auto_shop.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>State Machines</h2>
96
+
97
+ This class contains 1 state machine(s).
98
+
99
+
100
+ <h3>state</h3>
101
+ <p></p>
102
+
103
+
104
+ <img alt="State machine diagram for state" src="AutoShop_state.png" />
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
112
+ <ul class="summary">
113
+
114
+ <li class="public ">
115
+ <span class="summary_signature">
116
+
117
+ <a href="#state-instance_method" title="#state (instance method)">- (Object) <strong>state</strong> </a>
118
+
119
+
120
+
121
+ </span>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>
134
+ Gets the current attribute value for the machine.
135
+ </p>
136
+ </div></span>
137
+
138
+ </li>
139
+
140
+
141
+ </ul>
142
+
143
+
144
+
145
+
146
+
147
+ <h2>
148
+ Class Method Summary
149
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
150
+ </h2>
151
+
152
+ <ul class="summary">
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#human_state_event_name-class_method" title="human_state_event_name (class method)">+ (String) <strong>human_state_event_name</strong>(event) </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'><p>
171
+ Gets the humanized name for the given event.
172
+ </p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#human_state_name-class_method" title="human_state_name (class method)">+ (String) <strong>human_state_name</strong>(state) </a>
182
+
183
+
184
+
185
+ </span>
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <span class="summary_desc"><div class='inline'><p>
195
+ Gets the humanized name for the given state.
196
+ </p>
197
+ </div></span>
198
+
199
+ </li>
200
+
201
+
202
+ </ul>
203
+
204
+ <h2>
205
+ Instance Method Summary
206
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
207
+ </h2>
208
+
209
+ <ul class="summary">
210
+
211
+ <li class="public ">
212
+ <span class="summary_signature">
213
+
214
+ <a href="#available%3F-instance_method" title="#available? (instance method)">- (Boolean) <strong>available?</strong> </a>
215
+
216
+
217
+
218
+ </span>
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+ <span class="summary_desc"><div class='inline'><p>
228
+ Checks whether :available is the current state.
229
+ </p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ <li class="public ">
236
+ <span class="summary_signature">
237
+
238
+ <a href="#busy%3F-instance_method" title="#busy? (instance method)">- (Boolean) <strong>busy?</strong> </a>
239
+
240
+
241
+
242
+ </span>
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+ <span class="summary_desc"><div class='inline'><p>
252
+ Checks whether :busy is the current state.
253
+ </p>
254
+ </div></span>
255
+
256
+ </li>
257
+
258
+
259
+ <li class="public ">
260
+ <span class="summary_signature">
261
+
262
+ <a href="#can_fix_vehicle%3F-instance_method" title="#can_fix_vehicle? (instance method)">- (Boolean) <strong>can_fix_vehicle?</strong>(requirements = {}) </a>
263
+
264
+
265
+
266
+ </span>
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ <span class="summary_desc"><div class='inline'><p>
276
+ Checks whether :fix_vehicle can be fired.
277
+ </p>
278
+ </div></span>
279
+
280
+ </li>
281
+
282
+
283
+ <li class="public ">
284
+ <span class="summary_signature">
285
+
286
+ <a href="#can_tow_vehicle%3F-instance_method" title="#can_tow_vehicle? (instance method)">- (Boolean) <strong>can_tow_vehicle?</strong>(requirements = {}) </a>
287
+
288
+
289
+
290
+ </span>
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ <span class="summary_desc"><div class='inline'><p>
300
+ Checks whether :tow_vehicle can be fired.
301
+ </p>
302
+ </div></span>
303
+
304
+ </li>
305
+
306
+
307
+ <li class="public ">
308
+ <span class="summary_signature">
309
+
310
+ <a href="#fire_state_event-instance_method" title="#fire_state_event (instance method)">- (Boolean) <strong>fire_state_event</strong>(event, *args) </a>
311
+
312
+
313
+
314
+ </span>
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+ <span class="summary_desc"><div class='inline'><p>
324
+ Fires an arbitrary state event with the given argument list.
325
+ </p>
326
+ </div></span>
327
+
328
+ </li>
329
+
330
+
331
+ <li class="public ">
332
+ <span class="summary_signature">
333
+
334
+ <a href="#fix_vehicle-instance_method" title="#fix_vehicle (instance method)">- (Boolean) <strong>fix_vehicle</strong>(*args) </a>
335
+
336
+
337
+
338
+ </span>
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+ <span class="summary_desc"><div class='inline'><p>
348
+ Fires the :fix_vehicle event.
349
+ </p>
350
+ </div></span>
351
+
352
+ </li>
353
+
354
+
355
+ <li class="public ">
356
+ <span class="summary_signature">
357
+
358
+ <a href="#fix_vehicle%21-instance_method" title="#fix_vehicle! (instance method)">- (Boolean) <strong>fix_vehicle!</strong>(*args) </a>
359
+
360
+
361
+
362
+ </span>
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+ <span class="summary_desc"><div class='inline'><p>
372
+ Fires the :fix_vehicle event, raising an exception if it fails.
373
+ </p>
374
+ </div></span>
375
+
376
+ </li>
377
+
378
+
379
+ <li class="public ">
380
+ <span class="summary_signature">
381
+
382
+ <a href="#fix_vehicle_transition-instance_method" title="#fix_vehicle_transition (instance method)">- (StateMachine::Transition) <strong>fix_vehicle_transition</strong>(requirements = {}) </a>
383
+
384
+
385
+
386
+ </span>
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+ <span class="summary_desc"><div class='inline'><p>
396
+ Gets the next transition that would be performed if :fix_vehicle were to be
397
+ fired.
398
+ </p>
399
+ </div></span>
400
+
401
+ </li>
402
+
403
+
404
+ <li class="public ">
405
+ <span class="summary_signature">
406
+
407
+ <a href="#human_state_name-instance_method" title="#human_state_name (instance method)">- (String) <strong>human_state_name</strong> </a>
408
+
409
+
410
+
411
+ </span>
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+ <span class="summary_desc"><div class='inline'><p>
421
+ Gets the human-readable name of the state for the current value.
422
+ </p>
423
+ </div></span>
424
+
425
+ </li>
426
+
427
+
428
+ <li class="public ">
429
+ <span class="summary_signature">
430
+
431
+ <a href="#state%3F-instance_method" title="#state? (instance method)">- (Boolean) <strong>state?</strong>(state_name) </a>
432
+
433
+
434
+
435
+ </span>
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+ <span class="summary_desc"><div class='inline'><p>
445
+ Checks the given state name against the current state.
446
+ </p>
447
+ </div></span>
448
+
449
+ </li>
450
+
451
+
452
+ <li class="public ">
453
+ <span class="summary_signature">
454
+
455
+ <a href="#state_events-instance_method" title="#state_events (instance method)">- (Array&lt;Symbol&gt;) <strong>state_events</strong>(requirements = {}) </a>
456
+
457
+
458
+
459
+ </span>
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+ <span class="summary_desc"><div class='inline'><p>
469
+ Gets the list of events that can be fired on the current state (uses the
470
+ <b>unqualified</b> event names).
471
+ </p>
472
+ </div></span>
473
+
474
+ </li>
475
+
476
+
477
+ <li class="public ">
478
+ <span class="summary_signature">
479
+
480
+ <a href="#state_name-instance_method" title="#state_name (instance method)">- (Symbol) <strong>state_name</strong> </a>
481
+
482
+
483
+
484
+ </span>
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+ <span class="summary_desc"><div class='inline'><p>
494
+ Gets the internal name of the state for the current value.
495
+ </p>
496
+ </div></span>
497
+
498
+ </li>
499
+
500
+
501
+ <li class="public ">
502
+ <span class="summary_signature">
503
+
504
+ <a href="#state_paths-instance_method" title="#state_paths (instance method)">- (StateMachine::PathCollection) <strong>state_paths</strong>(requirements = {}) </a>
505
+
506
+
507
+
508
+ </span>
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+ <span class="summary_desc"><div class='inline'><p>
518
+ Gets the list of sequences of transitions that can be run for the current
519
+ state.
520
+ </p>
521
+ </div></span>
522
+
523
+ </li>
524
+
525
+
526
+ <li class="public ">
527
+ <span class="summary_signature">
528
+
529
+ <a href="#state_transitions-instance_method" title="#state_transitions (instance method)">- (Array&lt;StateMachine::Transition&gt;) <strong>state_transitions</strong>(requirements = {}) </a>
530
+
531
+
532
+
533
+ </span>
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+ <span class="summary_desc"><div class='inline'><p>
543
+ Gets the list of transitions that can be made for the current state.
544
+ </p>
545
+ </div></span>
546
+
547
+ </li>
548
+
549
+
550
+ <li class="public ">
551
+ <span class="summary_signature">
552
+
553
+ <a href="#tow_vehicle-instance_method" title="#tow_vehicle (instance method)">- (Boolean) <strong>tow_vehicle</strong>(*args) </a>
554
+
555
+
556
+
557
+ </span>
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+ <span class="summary_desc"><div class='inline'><p>
567
+ Fires the :tow_vehicle event.
568
+ </p>
569
+ </div></span>
570
+
571
+ </li>
572
+
573
+
574
+ <li class="public ">
575
+ <span class="summary_signature">
576
+
577
+ <a href="#tow_vehicle%21-instance_method" title="#tow_vehicle! (instance method)">- (Boolean) <strong>tow_vehicle!</strong>(*args) </a>
578
+
579
+
580
+
581
+ </span>
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+ <span class="summary_desc"><div class='inline'><p>
591
+ Fires the :tow_vehicle event, raising an exception if it fails.
592
+ </p>
593
+ </div></span>
594
+
595
+ </li>
596
+
597
+
598
+ <li class="public ">
599
+ <span class="summary_signature">
600
+
601
+ <a href="#tow_vehicle_transition-instance_method" title="#tow_vehicle_transition (instance method)">- (StateMachine::Transition) <strong>tow_vehicle_transition</strong>(requirements = {}) </a>
602
+
603
+
604
+
605
+ </span>
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+ <span class="summary_desc"><div class='inline'><p>
615
+ Gets the next transition that would be performed if :tow_vehicle were to be
616
+ fired.
617
+ </p>
618
+ </div></span>
619
+
620
+ </li>
621
+
622
+
623
+ </ul>
624
+
625
+
626
+
627
+ <div id="instance_attr_details" class="attr_details">
628
+ <h2>Instance Attribute Details</h2>
629
+
630
+
631
+ <span id="state=-instance_method"></span>
632
+ <span id="state-instance_method"></span>
633
+ <div class="method_details first">
634
+ <p class="signature first" id="state-instance_method">
635
+
636
+ - (<tt>Object</tt>) <strong>state</strong>
637
+
638
+
639
+
640
+ </p><div class="docstring">
641
+ <div class="discussion">
642
+ <p>
643
+ Gets the current attribute value for the machine
644
+ </p>
645
+
646
+
647
+ </div>
648
+ </div>
649
+ <div class="tags">
650
+
651
+ <h3>Returns:</h3>
652
+ <ul class="return">
653
+
654
+ <li>
655
+
656
+
657
+ <span class='type'></span>
658
+
659
+
660
+
661
+
662
+ <div class='inline'><p>
663
+ The attribute value
664
+ </p>
665
+ </div>
666
+
667
+ </li>
668
+
669
+ </ul>
670
+
671
+ </div><table class="source_code">
672
+ <tr>
673
+ <td>
674
+ <pre class="lines">
675
+
676
+
677
+ 4
678
+ 5
679
+ 6
680
+ 7
681
+ 8
682
+ 9
683
+ 10
684
+ 11
685
+ 12</pre>
686
+ </td>
687
+ <td>
688
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
689
+
690
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
691
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
692
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
693
+ <span class='kw'>end</span>
694
+
695
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
696
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
697
+ <span class='kw'>end</span>
698
+ <span class='kw'>end</span></pre>
699
+ </td>
700
+ </tr>
701
+ </table>
702
+ </div>
703
+
704
+ </div>
705
+
706
+
707
+ <div id="class_method_details" class="method_details_list">
708
+ <h2>Class Method Details</h2>
709
+
710
+
711
+ <div class="method_details first">
712
+ <p class="signature first" id="human_state_event_name-class_method">
713
+
714
+ + (<tt>String</tt>) <strong>human_state_event_name</strong>(event)
715
+
716
+
717
+
718
+ </p><div class="docstring">
719
+ <div class="discussion">
720
+ <p>
721
+ Gets the humanized name for the given event.
722
+ </p>
723
+
724
+
725
+ </div>
726
+ </div>
727
+ <div class="tags">
728
+ <h3>Parameters:</h3>
729
+ <ul class="param">
730
+
731
+ <li>
732
+
733
+ <span class='name'>event</span>
734
+
735
+
736
+ <span class='type'>(<tt>Symbol</tt>)</span>
737
+
738
+
739
+
740
+ &mdash;
741
+ <div class='inline'><p>
742
+ The event to look up
743
+ </p>
744
+ </div>
745
+
746
+ </li>
747
+
748
+ </ul>
749
+
750
+ <h3>Returns:</h3>
751
+ <ul class="return">
752
+
753
+ <li>
754
+
755
+
756
+ <span class='type'>(<tt>String</tt>)</span>
757
+
758
+
759
+
760
+ &mdash;
761
+ <div class='inline'><p>
762
+ The human event name
763
+ </p>
764
+ </div>
765
+
766
+ </li>
767
+
768
+ </ul>
769
+
770
+ </div><table class="source_code">
771
+ <tr>
772
+ <td>
773
+ <pre class="lines">
774
+
775
+
776
+ 4
777
+ 5
778
+ 6
779
+ 7
780
+ 8
781
+ 9
782
+ 10
783
+ 11
784
+ 12</pre>
785
+ </td>
786
+ <td>
787
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
788
+
789
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
790
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
791
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
792
+ <span class='kw'>end</span>
793
+
794
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
795
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
796
+ <span class='kw'>end</span>
797
+ <span class='kw'>end</span></pre>
798
+ </td>
799
+ </tr>
800
+ </table>
801
+ </div>
802
+
803
+ <div class="method_details ">
804
+ <p class="signature " id="human_state_name-class_method">
805
+
806
+ + (<tt>String</tt>) <strong>human_state_name</strong>(state)
807
+
808
+
809
+
810
+ </p><div class="docstring">
811
+ <div class="discussion">
812
+ <p>
813
+ Gets the humanized name for the given state.
814
+ </p>
815
+
816
+
817
+ </div>
818
+ </div>
819
+ <div class="tags">
820
+ <h3>Parameters:</h3>
821
+ <ul class="param">
822
+
823
+ <li>
824
+
825
+ <span class='name'>state</span>
826
+
827
+
828
+ <span class='type'>(<tt>Symbol</tt>)</span>
829
+
830
+
831
+
832
+ &mdash;
833
+ <div class='inline'><p>
834
+ The state to look up
835
+ </p>
836
+ </div>
837
+
838
+ </li>
839
+
840
+ </ul>
841
+
842
+ <h3>Returns:</h3>
843
+ <ul class="return">
844
+
845
+ <li>
846
+
847
+
848
+ <span class='type'>(<tt>String</tt>)</span>
849
+
850
+
851
+
852
+ &mdash;
853
+ <div class='inline'><p>
854
+ The human state name
855
+ </p>
856
+ </div>
857
+
858
+ </li>
859
+
860
+ </ul>
861
+
862
+ </div><table class="source_code">
863
+ <tr>
864
+ <td>
865
+ <pre class="lines">
866
+
867
+
868
+ 4
869
+ 5
870
+ 6
871
+ 7
872
+ 8
873
+ 9
874
+ 10
875
+ 11
876
+ 12</pre>
877
+ </td>
878
+ <td>
879
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
880
+
881
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
882
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
883
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
884
+ <span class='kw'>end</span>
885
+
886
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
887
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
888
+ <span class='kw'>end</span>
889
+ <span class='kw'>end</span></pre>
890
+ </td>
891
+ </tr>
892
+ </table>
893
+ </div>
894
+
895
+ </div>
896
+
897
+ <div id="instance_method_details" class="method_details_list">
898
+ <h2>Instance Method Details</h2>
899
+
900
+
901
+ <div class="method_details first">
902
+ <p class="signature first" id="available?-instance_method">
903
+
904
+ - (<tt>Boolean</tt>) <strong>available?</strong>
905
+
906
+
907
+
908
+ </p><div class="docstring">
909
+ <div class="discussion">
910
+ <p>
911
+ Checks whether :available is the current state.
912
+ </p>
913
+
914
+
915
+ </div>
916
+ </div>
917
+ <div class="tags">
918
+
919
+ <h3>Returns:</h3>
920
+ <ul class="return">
921
+
922
+ <li>
923
+
924
+
925
+ <span class='type'>(<tt>Boolean</tt>)</span>
926
+
927
+
928
+
929
+ &mdash;
930
+ <div class='inline'><p>
931
+ <tt>true</tt> if this is the current state, otherwise <tt>false</tt>
932
+ </p>
933
+ </div>
934
+
935
+ </li>
936
+
937
+ </ul>
938
+
939
+ </div><table class="source_code">
940
+ <tr>
941
+ <td>
942
+ <pre class="lines">
943
+
944
+
945
+ 4
946
+ 5
947
+ 6
948
+ 7
949
+ 8
950
+ 9
951
+ 10
952
+ 11
953
+ 12</pre>
954
+ </td>
955
+ <td>
956
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
957
+
958
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
959
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
960
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
961
+ <span class='kw'>end</span>
962
+
963
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
964
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
965
+ <span class='kw'>end</span>
966
+ <span class='kw'>end</span></pre>
967
+ </td>
968
+ </tr>
969
+ </table>
970
+ </div>
971
+
972
+ <div class="method_details ">
973
+ <p class="signature " id="busy?-instance_method">
974
+
975
+ - (<tt>Boolean</tt>) <strong>busy?</strong>
976
+
977
+
978
+
979
+ </p><div class="docstring">
980
+ <div class="discussion">
981
+ <p>
982
+ Checks whether :busy is the current state.
983
+ </p>
984
+
985
+
986
+ </div>
987
+ </div>
988
+ <div class="tags">
989
+
990
+ <h3>Returns:</h3>
991
+ <ul class="return">
992
+
993
+ <li>
994
+
995
+
996
+ <span class='type'>(<tt>Boolean</tt>)</span>
997
+
998
+
999
+
1000
+ &mdash;
1001
+ <div class='inline'><p>
1002
+ <tt>true</tt> if this is the current state, otherwise <tt>false</tt>
1003
+ </p>
1004
+ </div>
1005
+
1006
+ </li>
1007
+
1008
+ </ul>
1009
+
1010
+ </div><table class="source_code">
1011
+ <tr>
1012
+ <td>
1013
+ <pre class="lines">
1014
+
1015
+
1016
+ 4
1017
+ 5
1018
+ 6
1019
+ 7
1020
+ 8
1021
+ 9
1022
+ 10
1023
+ 11
1024
+ 12</pre>
1025
+ </td>
1026
+ <td>
1027
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1028
+
1029
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1030
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1031
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1032
+ <span class='kw'>end</span>
1033
+
1034
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1035
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1036
+ <span class='kw'>end</span>
1037
+ <span class='kw'>end</span></pre>
1038
+ </td>
1039
+ </tr>
1040
+ </table>
1041
+ </div>
1042
+
1043
+ <div class="method_details ">
1044
+ <p class="signature " id="can_fix_vehicle?-instance_method">
1045
+
1046
+ - (<tt>Boolean</tt>) <strong>can_fix_vehicle?</strong>(requirements = {})
1047
+
1048
+
1049
+
1050
+ </p><div class="docstring">
1051
+ <div class="discussion">
1052
+ <p>
1053
+ Checks whether :fix_vehicle can be fired.
1054
+ </p>
1055
+
1056
+
1057
+ </div>
1058
+ </div>
1059
+ <div class="tags">
1060
+ <h3>Parameters:</h3>
1061
+ <ul class="param">
1062
+
1063
+ <li>
1064
+
1065
+ <span class='name'>requirements</span>
1066
+
1067
+
1068
+ <span class='type'>(<tt>Hash</tt>)</span>
1069
+
1070
+
1071
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1072
+
1073
+
1074
+ &mdash;
1075
+ <div class='inline'><p>
1076
+ The transition requirements to test against
1077
+ </p>
1078
+ </div>
1079
+
1080
+ </li>
1081
+
1082
+ </ul>
1083
+
1084
+
1085
+
1086
+
1087
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1088
+ <ul class="option">
1089
+
1090
+ <li>
1091
+ <span class="name">:from</span>
1092
+ <span class="type">(<tt>Symbol</tt>)</span>
1093
+ <span class="default">
1094
+
1095
+ &mdash; default:
1096
+ <tt>the current state</tt>
1097
+
1098
+ </span>
1099
+ &mdash; <div class='inline'><p>
1100
+ One or more initial states
1101
+ </p>
1102
+ </div>
1103
+ </li>
1104
+
1105
+ <li>
1106
+ <span class="name">:to</span>
1107
+ <span class="type">(<tt>Symbol</tt>)</span>
1108
+ <span class="default">
1109
+
1110
+ </span>
1111
+ &mdash; <div class='inline'><p>
1112
+ One or more target states
1113
+ </p>
1114
+ </div>
1115
+ </li>
1116
+
1117
+ <li>
1118
+ <span class="name">:guard</span>
1119
+ <span class="type">(<tt>Boolean</tt>)</span>
1120
+ <span class="default">
1121
+
1122
+ </span>
1123
+ &mdash; <div class='inline'><p>
1124
+ Whether to guard transitions with conditionals
1125
+ </p>
1126
+ </div>
1127
+ </li>
1128
+
1129
+ </ul>
1130
+
1131
+
1132
+ <h3>Returns:</h3>
1133
+ <ul class="return">
1134
+
1135
+ <li>
1136
+
1137
+
1138
+ <span class='type'>(<tt>Boolean</tt>)</span>
1139
+
1140
+
1141
+
1142
+ &mdash;
1143
+ <div class='inline'><p>
1144
+ <tt>true</tt> if :fix_vehicle can be fired, otherwise <tt>false</tt>
1145
+ </p>
1146
+ </div>
1147
+
1148
+ </li>
1149
+
1150
+ </ul>
1151
+
1152
+ </div><table class="source_code">
1153
+ <tr>
1154
+ <td>
1155
+ <pre class="lines">
1156
+
1157
+
1158
+ 4
1159
+ 5
1160
+ 6
1161
+ 7
1162
+ 8
1163
+ 9
1164
+ 10
1165
+ 11
1166
+ 12</pre>
1167
+ </td>
1168
+ <td>
1169
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1170
+
1171
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1172
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1173
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1174
+ <span class='kw'>end</span>
1175
+
1176
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1177
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1178
+ <span class='kw'>end</span>
1179
+ <span class='kw'>end</span></pre>
1180
+ </td>
1181
+ </tr>
1182
+ </table>
1183
+ </div>
1184
+
1185
+ <div class="method_details ">
1186
+ <p class="signature " id="can_tow_vehicle?-instance_method">
1187
+
1188
+ - (<tt>Boolean</tt>) <strong>can_tow_vehicle?</strong>(requirements = {})
1189
+
1190
+
1191
+
1192
+ </p><div class="docstring">
1193
+ <div class="discussion">
1194
+ <p>
1195
+ Checks whether :tow_vehicle can be fired.
1196
+ </p>
1197
+
1198
+
1199
+ </div>
1200
+ </div>
1201
+ <div class="tags">
1202
+ <h3>Parameters:</h3>
1203
+ <ul class="param">
1204
+
1205
+ <li>
1206
+
1207
+ <span class='name'>requirements</span>
1208
+
1209
+
1210
+ <span class='type'>(<tt>Hash</tt>)</span>
1211
+
1212
+
1213
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1214
+
1215
+
1216
+ &mdash;
1217
+ <div class='inline'><p>
1218
+ The transition requirements to test against
1219
+ </p>
1220
+ </div>
1221
+
1222
+ </li>
1223
+
1224
+ </ul>
1225
+
1226
+
1227
+
1228
+
1229
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1230
+ <ul class="option">
1231
+
1232
+ <li>
1233
+ <span class="name">:from</span>
1234
+ <span class="type">(<tt>Symbol</tt>)</span>
1235
+ <span class="default">
1236
+
1237
+ &mdash; default:
1238
+ <tt>the current state</tt>
1239
+
1240
+ </span>
1241
+ &mdash; <div class='inline'><p>
1242
+ One or more initial states
1243
+ </p>
1244
+ </div>
1245
+ </li>
1246
+
1247
+ <li>
1248
+ <span class="name">:to</span>
1249
+ <span class="type">(<tt>Symbol</tt>)</span>
1250
+ <span class="default">
1251
+
1252
+ </span>
1253
+ &mdash; <div class='inline'><p>
1254
+ One or more target states
1255
+ </p>
1256
+ </div>
1257
+ </li>
1258
+
1259
+ <li>
1260
+ <span class="name">:guard</span>
1261
+ <span class="type">(<tt>Boolean</tt>)</span>
1262
+ <span class="default">
1263
+
1264
+ </span>
1265
+ &mdash; <div class='inline'><p>
1266
+ Whether to guard transitions with conditionals
1267
+ </p>
1268
+ </div>
1269
+ </li>
1270
+
1271
+ </ul>
1272
+
1273
+
1274
+ <h3>Returns:</h3>
1275
+ <ul class="return">
1276
+
1277
+ <li>
1278
+
1279
+
1280
+ <span class='type'>(<tt>Boolean</tt>)</span>
1281
+
1282
+
1283
+
1284
+ &mdash;
1285
+ <div class='inline'><p>
1286
+ <tt>true</tt> if :tow_vehicle can be fired, otherwise <tt>false</tt>
1287
+ </p>
1288
+ </div>
1289
+
1290
+ </li>
1291
+
1292
+ </ul>
1293
+
1294
+ </div><table class="source_code">
1295
+ <tr>
1296
+ <td>
1297
+ <pre class="lines">
1298
+
1299
+
1300
+ 4
1301
+ 5
1302
+ 6
1303
+ 7
1304
+ 8
1305
+ 9
1306
+ 10
1307
+ 11
1308
+ 12</pre>
1309
+ </td>
1310
+ <td>
1311
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1312
+
1313
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1314
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1315
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1316
+ <span class='kw'>end</span>
1317
+
1318
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1319
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1320
+ <span class='kw'>end</span>
1321
+ <span class='kw'>end</span></pre>
1322
+ </td>
1323
+ </tr>
1324
+ </table>
1325
+ </div>
1326
+
1327
+ <div class="method_details ">
1328
+ <p class="signature " id="fire_state_event-instance_method">
1329
+
1330
+ - (<tt>Boolean</tt>) <strong>fire_state_event</strong>(event, *args)
1331
+
1332
+
1333
+
1334
+ </p><div class="docstring">
1335
+ <div class="discussion">
1336
+ <p>
1337
+ Fires an arbitrary state event with the given argument list
1338
+ </p>
1339
+
1340
+
1341
+ </div>
1342
+ </div>
1343
+ <div class="tags">
1344
+ <h3>Parameters:</h3>
1345
+ <ul class="param">
1346
+
1347
+ <li>
1348
+
1349
+ <span class='name'>event</span>
1350
+
1351
+
1352
+ <span class='type'>(<tt>Symbol</tt>)</span>
1353
+
1354
+
1355
+
1356
+ &mdash;
1357
+ <div class='inline'><p>
1358
+ The name of the event to fire
1359
+ </p>
1360
+ </div>
1361
+
1362
+ </li>
1363
+
1364
+ <li>
1365
+
1366
+ <span class='name'>args</span>
1367
+
1368
+
1369
+ <span class='type'></span>
1370
+
1371
+
1372
+
1373
+ &mdash;
1374
+ <div class='inline'><p>
1375
+ Optional arguments to include in the transition
1376
+ </p>
1377
+ </div>
1378
+
1379
+ </li>
1380
+
1381
+ </ul>
1382
+
1383
+ <h3>Returns:</h3>
1384
+ <ul class="return">
1385
+
1386
+ <li>
1387
+
1388
+
1389
+ <span class='type'>(<tt>Boolean</tt>)</span>
1390
+
1391
+
1392
+
1393
+ &mdash;
1394
+ <div class='inline'><p>
1395
+ <tt>true</tt> if the event succeeds, otherwise <tt>false</tt>
1396
+ </p>
1397
+ </div>
1398
+
1399
+ </li>
1400
+
1401
+ </ul>
1402
+
1403
+ </div><table class="source_code">
1404
+ <tr>
1405
+ <td>
1406
+ <pre class="lines">
1407
+
1408
+
1409
+ 4
1410
+ 5
1411
+ 6
1412
+ 7
1413
+ 8
1414
+ 9
1415
+ 10
1416
+ 11
1417
+ 12</pre>
1418
+ </td>
1419
+ <td>
1420
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1421
+
1422
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1423
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1424
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1425
+ <span class='kw'>end</span>
1426
+
1427
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1428
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1429
+ <span class='kw'>end</span>
1430
+ <span class='kw'>end</span></pre>
1431
+ </td>
1432
+ </tr>
1433
+ </table>
1434
+ </div>
1435
+
1436
+ <div class="method_details ">
1437
+ <p class="signature " id="fix_vehicle-instance_method">
1438
+
1439
+ - (<tt>Boolean</tt>) <strong>fix_vehicle</strong>(*args)
1440
+
1441
+
1442
+
1443
+ </p><div class="docstring">
1444
+ <div class="discussion">
1445
+ <p>
1446
+ Fires the :fix_vehicle event.
1447
+ </p>
1448
+
1449
+
1450
+ </div>
1451
+ </div>
1452
+ <div class="tags">
1453
+ <h3>Parameters:</h3>
1454
+ <ul class="param">
1455
+
1456
+ <li>
1457
+
1458
+ <span class='name'>args</span>
1459
+
1460
+
1461
+ <span class='type'>(<tt>Array</tt>)</span>
1462
+
1463
+
1464
+
1465
+ &mdash;
1466
+ <div class='inline'><p>
1467
+ Optional arguments to include in transition callbacks
1468
+ </p>
1469
+ </div>
1470
+
1471
+ </li>
1472
+
1473
+ </ul>
1474
+
1475
+ <h3>Returns:</h3>
1476
+ <ul class="return">
1477
+
1478
+ <li>
1479
+
1480
+
1481
+ <span class='type'>(<tt>Boolean</tt>)</span>
1482
+
1483
+
1484
+
1485
+ &mdash;
1486
+ <div class='inline'><p>
1487
+ <tt>true</tt> if the transition succeeds, otherwise <tt>false</tt>
1488
+ </p>
1489
+ </div>
1490
+
1491
+ </li>
1492
+
1493
+ </ul>
1494
+
1495
+ </div><table class="source_code">
1496
+ <tr>
1497
+ <td>
1498
+ <pre class="lines">
1499
+
1500
+
1501
+ 4
1502
+ 5
1503
+ 6
1504
+ 7
1505
+ 8
1506
+ 9
1507
+ 10
1508
+ 11
1509
+ 12</pre>
1510
+ </td>
1511
+ <td>
1512
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1513
+
1514
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1515
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1516
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1517
+ <span class='kw'>end</span>
1518
+
1519
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1520
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1521
+ <span class='kw'>end</span>
1522
+ <span class='kw'>end</span></pre>
1523
+ </td>
1524
+ </tr>
1525
+ </table>
1526
+ </div>
1527
+
1528
+ <div class="method_details ">
1529
+ <p class="signature " id="fix_vehicle!-instance_method">
1530
+
1531
+ - (<tt>Boolean</tt>) <strong>fix_vehicle!</strong>(*args)
1532
+
1533
+
1534
+
1535
+ </p><div class="docstring">
1536
+ <div class="discussion">
1537
+ <p>
1538
+ Fires the :fix_vehicle event, raising an exception if it fails.
1539
+ </p>
1540
+
1541
+
1542
+ </div>
1543
+ </div>
1544
+ <div class="tags">
1545
+ <h3>Parameters:</h3>
1546
+ <ul class="param">
1547
+
1548
+ <li>
1549
+
1550
+ <span class='name'>args</span>
1551
+
1552
+
1553
+ <span class='type'>(<tt>Array</tt>)</span>
1554
+
1555
+
1556
+
1557
+ &mdash;
1558
+ <div class='inline'><p>
1559
+ Optional arguments to include in transition callbacks
1560
+ </p>
1561
+ </div>
1562
+
1563
+ </li>
1564
+
1565
+ </ul>
1566
+
1567
+ <h3>Returns:</h3>
1568
+ <ul class="return">
1569
+
1570
+ <li>
1571
+
1572
+
1573
+ <span class='type'>(<tt>Boolean</tt>)</span>
1574
+
1575
+
1576
+
1577
+ &mdash;
1578
+ <div class='inline'><p>
1579
+ <tt>true</tt> if the transition succeeds
1580
+ </p>
1581
+ </div>
1582
+
1583
+ </li>
1584
+
1585
+ </ul>
1586
+ <h3>Raises:</h3>
1587
+ <ul class="raise">
1588
+
1589
+ <li>
1590
+
1591
+
1592
+ <span class='type'>(<tt>StateMachine::InvalidTransition</tt>)</span>
1593
+
1594
+
1595
+
1596
+ &mdash;
1597
+ <div class='inline'><p>
1598
+ If the transition fails
1599
+ </p>
1600
+ </div>
1601
+
1602
+ </li>
1603
+
1604
+ </ul>
1605
+
1606
+ </div><table class="source_code">
1607
+ <tr>
1608
+ <td>
1609
+ <pre class="lines">
1610
+
1611
+
1612
+ 4
1613
+ 5
1614
+ 6
1615
+ 7
1616
+ 8
1617
+ 9
1618
+ 10
1619
+ 11
1620
+ 12</pre>
1621
+ </td>
1622
+ <td>
1623
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1624
+
1625
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1626
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1627
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1628
+ <span class='kw'>end</span>
1629
+
1630
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1631
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1632
+ <span class='kw'>end</span>
1633
+ <span class='kw'>end</span></pre>
1634
+ </td>
1635
+ </tr>
1636
+ </table>
1637
+ </div>
1638
+
1639
+ <div class="method_details ">
1640
+ <p class="signature " id="fix_vehicle_transition-instance_method">
1641
+
1642
+ - (<tt>StateMachine::Transition</tt>) <strong>fix_vehicle_transition</strong>(requirements = {})
1643
+
1644
+
1645
+
1646
+ </p><div class="docstring">
1647
+ <div class="discussion">
1648
+ <p>
1649
+ Gets the next transition that would be performed if :fix_vehicle were to be
1650
+ fired.
1651
+ </p>
1652
+
1653
+
1654
+ </div>
1655
+ </div>
1656
+ <div class="tags">
1657
+ <h3>Parameters:</h3>
1658
+ <ul class="param">
1659
+
1660
+ <li>
1661
+
1662
+ <span class='name'>requirements</span>
1663
+
1664
+
1665
+ <span class='type'>(<tt>Hash</tt>)</span>
1666
+
1667
+
1668
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1669
+
1670
+
1671
+ &mdash;
1672
+ <div class='inline'><p>
1673
+ The transition requirements to test against
1674
+ </p>
1675
+ </div>
1676
+
1677
+ </li>
1678
+
1679
+ </ul>
1680
+
1681
+
1682
+
1683
+
1684
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1685
+ <ul class="option">
1686
+
1687
+ <li>
1688
+ <span class="name">:from</span>
1689
+ <span class="type">(<tt>Symbol</tt>)</span>
1690
+ <span class="default">
1691
+
1692
+ &mdash; default:
1693
+ <tt>the current state</tt>
1694
+
1695
+ </span>
1696
+ &mdash; <div class='inline'><p>
1697
+ One or more initial states
1698
+ </p>
1699
+ </div>
1700
+ </li>
1701
+
1702
+ <li>
1703
+ <span class="name">:to</span>
1704
+ <span class="type">(<tt>Symbol</tt>)</span>
1705
+ <span class="default">
1706
+
1707
+ </span>
1708
+ &mdash; <div class='inline'><p>
1709
+ One or more target states
1710
+ </p>
1711
+ </div>
1712
+ </li>
1713
+
1714
+ <li>
1715
+ <span class="name">:guard</span>
1716
+ <span class="type">(<tt>Boolean</tt>)</span>
1717
+ <span class="default">
1718
+
1719
+ </span>
1720
+ &mdash; <div class='inline'><p>
1721
+ Whether to guard transitions with conditionals
1722
+ </p>
1723
+ </div>
1724
+ </li>
1725
+
1726
+ </ul>
1727
+
1728
+
1729
+ <h3>Returns:</h3>
1730
+ <ul class="return">
1731
+
1732
+ <li>
1733
+
1734
+
1735
+ <span class='type'>(<tt>StateMachine::Transition</tt>)</span>
1736
+
1737
+
1738
+
1739
+ &mdash;
1740
+ <div class='inline'><p>
1741
+ The transition that would be performed or <tt>nil</tt>
1742
+ </p>
1743
+ </div>
1744
+
1745
+ </li>
1746
+
1747
+ </ul>
1748
+
1749
+ </div><table class="source_code">
1750
+ <tr>
1751
+ <td>
1752
+ <pre class="lines">
1753
+
1754
+
1755
+ 4
1756
+ 5
1757
+ 6
1758
+ 7
1759
+ 8
1760
+ 9
1761
+ 10
1762
+ 11
1763
+ 12</pre>
1764
+ </td>
1765
+ <td>
1766
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1767
+
1768
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1769
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1770
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1771
+ <span class='kw'>end</span>
1772
+
1773
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1774
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1775
+ <span class='kw'>end</span>
1776
+ <span class='kw'>end</span></pre>
1777
+ </td>
1778
+ </tr>
1779
+ </table>
1780
+ </div>
1781
+
1782
+ <div class="method_details ">
1783
+ <p class="signature " id="human_state_name-instance_method">
1784
+
1785
+ - (<tt>String</tt>) <strong>human_state_name</strong>
1786
+
1787
+
1788
+
1789
+ </p><div class="docstring">
1790
+ <div class="discussion">
1791
+ <p>
1792
+ Gets the human-readable name of the state for the current value.
1793
+ </p>
1794
+
1795
+
1796
+ </div>
1797
+ </div>
1798
+ <div class="tags">
1799
+
1800
+ <h3>Returns:</h3>
1801
+ <ul class="return">
1802
+
1803
+ <li>
1804
+
1805
+
1806
+ <span class='type'>(<tt>String</tt>)</span>
1807
+
1808
+
1809
+
1810
+ &mdash;
1811
+ <div class='inline'><p>
1812
+ The human-readable state name
1813
+ </p>
1814
+ </div>
1815
+
1816
+ </li>
1817
+
1818
+ </ul>
1819
+
1820
+ </div><table class="source_code">
1821
+ <tr>
1822
+ <td>
1823
+ <pre class="lines">
1824
+
1825
+
1826
+ 4
1827
+ 5
1828
+ 6
1829
+ 7
1830
+ 8
1831
+ 9
1832
+ 10
1833
+ 11
1834
+ 12</pre>
1835
+ </td>
1836
+ <td>
1837
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1838
+
1839
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1840
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1841
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1842
+ <span class='kw'>end</span>
1843
+
1844
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1845
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1846
+ <span class='kw'>end</span>
1847
+ <span class='kw'>end</span></pre>
1848
+ </td>
1849
+ </tr>
1850
+ </table>
1851
+ </div>
1852
+
1853
+ <div class="method_details ">
1854
+ <p class="signature " id="state?-instance_method">
1855
+
1856
+ - (<tt>Boolean</tt>) <strong>state?</strong>(state_name)
1857
+
1858
+
1859
+
1860
+ </p><div class="docstring">
1861
+ <div class="discussion">
1862
+ <p>
1863
+ Checks the given state name against the current state.
1864
+ </p>
1865
+
1866
+
1867
+ </div>
1868
+ </div>
1869
+ <div class="tags">
1870
+ <h3>Parameters:</h3>
1871
+ <ul class="param">
1872
+
1873
+ <li>
1874
+
1875
+ <span class='name'>state_name</span>
1876
+
1877
+
1878
+ <span class='type'>(<tt>Symbol</tt>)</span>
1879
+
1880
+
1881
+
1882
+ &mdash;
1883
+ <div class='inline'><p>
1884
+ The name of the state to check
1885
+ </p>
1886
+ </div>
1887
+
1888
+ </li>
1889
+
1890
+ </ul>
1891
+
1892
+ <h3>Returns:</h3>
1893
+ <ul class="return">
1894
+
1895
+ <li>
1896
+
1897
+
1898
+ <span class='type'>(<tt>Boolean</tt>)</span>
1899
+
1900
+
1901
+
1902
+ &mdash;
1903
+ <div class='inline'><p>
1904
+ True if they are the same state, otherwise false
1905
+ </p>
1906
+ </div>
1907
+
1908
+ </li>
1909
+
1910
+ </ul>
1911
+ <h3>Raises:</h3>
1912
+ <ul class="raise">
1913
+
1914
+ <li>
1915
+
1916
+
1917
+ <span class='type'>(<tt>IndexError</tt>)</span>
1918
+
1919
+
1920
+
1921
+ &mdash;
1922
+ <div class='inline'><p>
1923
+ If the state name is invalid
1924
+ </p>
1925
+ </div>
1926
+
1927
+ </li>
1928
+
1929
+ </ul>
1930
+
1931
+ </div><table class="source_code">
1932
+ <tr>
1933
+ <td>
1934
+ <pre class="lines">
1935
+
1936
+
1937
+ 4
1938
+ 5
1939
+ 6
1940
+ 7
1941
+ 8
1942
+ 9
1943
+ 10
1944
+ 11
1945
+ 12</pre>
1946
+ </td>
1947
+ <td>
1948
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
1949
+
1950
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
1951
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
1952
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
1953
+ <span class='kw'>end</span>
1954
+
1955
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
1956
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
1957
+ <span class='kw'>end</span>
1958
+ <span class='kw'>end</span></pre>
1959
+ </td>
1960
+ </tr>
1961
+ </table>
1962
+ </div>
1963
+
1964
+ <div class="method_details ">
1965
+ <p class="signature " id="state_events-instance_method">
1966
+
1967
+ - (<tt>Array&lt;Symbol&gt;</tt>) <strong>state_events</strong>(requirements = {})
1968
+
1969
+
1970
+
1971
+ </p><div class="docstring">
1972
+ <div class="discussion">
1973
+ <p>
1974
+ Gets the list of events that can be fired on the current state (uses the
1975
+ <b>unqualified</b> event names)
1976
+ </p>
1977
+
1978
+
1979
+ </div>
1980
+ </div>
1981
+ <div class="tags">
1982
+ <h3>Parameters:</h3>
1983
+ <ul class="param">
1984
+
1985
+ <li>
1986
+
1987
+ <span class='name'>requirements</span>
1988
+
1989
+
1990
+ <span class='type'>(<tt>Hash</tt>)</span>
1991
+
1992
+
1993
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1994
+
1995
+
1996
+ &mdash;
1997
+ <div class='inline'><p>
1998
+ The transition requirements to test against
1999
+ </p>
2000
+ </div>
2001
+
2002
+ </li>
2003
+
2004
+ </ul>
2005
+
2006
+
2007
+
2008
+
2009
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
2010
+ <ul class="option">
2011
+
2012
+ <li>
2013
+ <span class="name">:from</span>
2014
+ <span class="type">(<tt>Symbol</tt>)</span>
2015
+ <span class="default">
2016
+
2017
+ &mdash; default:
2018
+ <tt>the current state</tt>
2019
+
2020
+ </span>
2021
+ &mdash; <div class='inline'><p>
2022
+ One or more initial states
2023
+ </p>
2024
+ </div>
2025
+ </li>
2026
+
2027
+ <li>
2028
+ <span class="name">:to</span>
2029
+ <span class="type">(<tt>Symbol</tt>)</span>
2030
+ <span class="default">
2031
+
2032
+ </span>
2033
+ &mdash; <div class='inline'><p>
2034
+ One or more target states
2035
+ </p>
2036
+ </div>
2037
+ </li>
2038
+
2039
+ <li>
2040
+ <span class="name">:on</span>
2041
+ <span class="type">(<tt>Symbol</tt>)</span>
2042
+ <span class="default">
2043
+
2044
+ </span>
2045
+ &mdash; <div class='inline'><p>
2046
+ One or more events that fire the transition
2047
+ </p>
2048
+ </div>
2049
+ </li>
2050
+
2051
+ <li>
2052
+ <span class="name">:guard</span>
2053
+ <span class="type">(<tt>Boolean</tt>)</span>
2054
+ <span class="default">
2055
+
2056
+ </span>
2057
+ &mdash; <div class='inline'><p>
2058
+ Whether to guard transitions with conditionals
2059
+ </p>
2060
+ </div>
2061
+ </li>
2062
+
2063
+ </ul>
2064
+
2065
+
2066
+ <h3>Returns:</h3>
2067
+ <ul class="return">
2068
+
2069
+ <li>
2070
+
2071
+
2072
+ <span class='type'>(<tt>Array&lt;Symbol&gt;</tt>)</span>
2073
+
2074
+
2075
+
2076
+ &mdash;
2077
+ <div class='inline'><p>
2078
+ The list of event names
2079
+ </p>
2080
+ </div>
2081
+
2082
+ </li>
2083
+
2084
+ </ul>
2085
+
2086
+ </div><table class="source_code">
2087
+ <tr>
2088
+ <td>
2089
+ <pre class="lines">
2090
+
2091
+
2092
+ 4
2093
+ 5
2094
+ 6
2095
+ 7
2096
+ 8
2097
+ 9
2098
+ 10
2099
+ 11
2100
+ 12</pre>
2101
+ </td>
2102
+ <td>
2103
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2104
+
2105
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2106
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2107
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2108
+ <span class='kw'>end</span>
2109
+
2110
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2111
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2112
+ <span class='kw'>end</span>
2113
+ <span class='kw'>end</span></pre>
2114
+ </td>
2115
+ </tr>
2116
+ </table>
2117
+ </div>
2118
+
2119
+ <div class="method_details ">
2120
+ <p class="signature " id="state_name-instance_method">
2121
+
2122
+ - (<tt>Symbol</tt>) <strong>state_name</strong>
2123
+
2124
+
2125
+
2126
+ </p><div class="docstring">
2127
+ <div class="discussion">
2128
+ <p>
2129
+ Gets the internal name of the state for the current value.
2130
+ </p>
2131
+
2132
+
2133
+ </div>
2134
+ </div>
2135
+ <div class="tags">
2136
+
2137
+ <h3>Returns:</h3>
2138
+ <ul class="return">
2139
+
2140
+ <li>
2141
+
2142
+
2143
+ <span class='type'>(<tt>Symbol</tt>)</span>
2144
+
2145
+
2146
+
2147
+ &mdash;
2148
+ <div class='inline'><p>
2149
+ The internal name of the state
2150
+ </p>
2151
+ </div>
2152
+
2153
+ </li>
2154
+
2155
+ </ul>
2156
+
2157
+ </div><table class="source_code">
2158
+ <tr>
2159
+ <td>
2160
+ <pre class="lines">
2161
+
2162
+
2163
+ 4
2164
+ 5
2165
+ 6
2166
+ 7
2167
+ 8
2168
+ 9
2169
+ 10
2170
+ 11
2171
+ 12</pre>
2172
+ </td>
2173
+ <td>
2174
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2175
+
2176
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2177
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2178
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2179
+ <span class='kw'>end</span>
2180
+
2181
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2182
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2183
+ <span class='kw'>end</span>
2184
+ <span class='kw'>end</span></pre>
2185
+ </td>
2186
+ </tr>
2187
+ </table>
2188
+ </div>
2189
+
2190
+ <div class="method_details ">
2191
+ <p class="signature " id="state_paths-instance_method">
2192
+
2193
+ - (<tt>StateMachine::PathCollection</tt>) <strong>state_paths</strong>(requirements = {})
2194
+
2195
+
2196
+
2197
+ </p><div class="docstring">
2198
+ <div class="discussion">
2199
+ <p>
2200
+ Gets the list of sequences of transitions that can be run for the current
2201
+ state
2202
+ </p>
2203
+
2204
+
2205
+ </div>
2206
+ </div>
2207
+ <div class="tags">
2208
+ <h3>Parameters:</h3>
2209
+ <ul class="param">
2210
+
2211
+ <li>
2212
+
2213
+ <span class='name'>requirements</span>
2214
+
2215
+
2216
+ <span class='type'>(<tt>Hash</tt>)</span>
2217
+
2218
+
2219
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2220
+
2221
+
2222
+ &mdash;
2223
+ <div class='inline'><p>
2224
+ The transition requirements to test against
2225
+ </p>
2226
+ </div>
2227
+
2228
+ </li>
2229
+
2230
+ </ul>
2231
+
2232
+
2233
+
2234
+
2235
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
2236
+ <ul class="option">
2237
+
2238
+ <li>
2239
+ <span class="name">:from</span>
2240
+ <span class="type">(<tt>Symbol</tt>)</span>
2241
+ <span class="default">
2242
+
2243
+ &mdash; default:
2244
+ <tt>the current state</tt>
2245
+
2246
+ </span>
2247
+ &mdash; <div class='inline'><p>
2248
+ The initial state
2249
+ </p>
2250
+ </div>
2251
+ </li>
2252
+
2253
+ <li>
2254
+ <span class="name">:to</span>
2255
+ <span class="type">(<tt>Symbol</tt>)</span>
2256
+ <span class="default">
2257
+
2258
+ </span>
2259
+ &mdash; <div class='inline'><p>
2260
+ The target state
2261
+ </p>
2262
+ </div>
2263
+ </li>
2264
+
2265
+ <li>
2266
+ <span class="name">:deep</span>
2267
+ <span class="type">(<tt>Boolean</tt>)</span>
2268
+ <span class="default">
2269
+
2270
+ </span>
2271
+ &mdash; <div class='inline'><p>
2272
+ Whether to enable deep searches for the target state
2273
+ </p>
2274
+ </div>
2275
+ </li>
2276
+
2277
+ <li>
2278
+ <span class="name">:guard</span>
2279
+ <span class="type">(<tt>Boolean</tt>)</span>
2280
+ <span class="default">
2281
+
2282
+ </span>
2283
+ &mdash; <div class='inline'><p>
2284
+ Whether to guard transitions with conditionals
2285
+ </p>
2286
+ </div>
2287
+ </li>
2288
+
2289
+ </ul>
2290
+
2291
+
2292
+ <h3>Returns:</h3>
2293
+ <ul class="return">
2294
+
2295
+ <li>
2296
+
2297
+
2298
+ <span class='type'>(<tt>StateMachine::PathCollection</tt>)</span>
2299
+
2300
+
2301
+
2302
+ &mdash;
2303
+ <div class='inline'><p>
2304
+ The collection of paths
2305
+ </p>
2306
+ </div>
2307
+
2308
+ </li>
2309
+
2310
+ </ul>
2311
+
2312
+ </div><table class="source_code">
2313
+ <tr>
2314
+ <td>
2315
+ <pre class="lines">
2316
+
2317
+
2318
+ 4
2319
+ 5
2320
+ 6
2321
+ 7
2322
+ 8
2323
+ 9
2324
+ 10
2325
+ 11
2326
+ 12</pre>
2327
+ </td>
2328
+ <td>
2329
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2330
+
2331
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2332
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2333
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2334
+ <span class='kw'>end</span>
2335
+
2336
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2337
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2338
+ <span class='kw'>end</span>
2339
+ <span class='kw'>end</span></pre>
2340
+ </td>
2341
+ </tr>
2342
+ </table>
2343
+ </div>
2344
+
2345
+ <div class="method_details ">
2346
+ <p class="signature " id="state_transitions-instance_method">
2347
+
2348
+ - (<tt>Array&lt;StateMachine::Transition&gt;</tt>) <strong>state_transitions</strong>(requirements = {})
2349
+
2350
+
2351
+
2352
+ </p><div class="docstring">
2353
+ <div class="discussion">
2354
+ <p>
2355
+ Gets the list of transitions that can be made for the current state
2356
+ </p>
2357
+
2358
+
2359
+ </div>
2360
+ </div>
2361
+ <div class="tags">
2362
+ <h3>Parameters:</h3>
2363
+ <ul class="param">
2364
+
2365
+ <li>
2366
+
2367
+ <span class='name'>requirements</span>
2368
+
2369
+
2370
+ <span class='type'>(<tt>Hash</tt>)</span>
2371
+
2372
+
2373
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2374
+
2375
+
2376
+ &mdash;
2377
+ <div class='inline'><p>
2378
+ The transition requirements to test against
2379
+ </p>
2380
+ </div>
2381
+
2382
+ </li>
2383
+
2384
+ </ul>
2385
+
2386
+
2387
+
2388
+
2389
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
2390
+ <ul class="option">
2391
+
2392
+ <li>
2393
+ <span class="name">:from</span>
2394
+ <span class="type">(<tt>Symbol</tt>)</span>
2395
+ <span class="default">
2396
+
2397
+ &mdash; default:
2398
+ <tt>the current state</tt>
2399
+
2400
+ </span>
2401
+ &mdash; <div class='inline'><p>
2402
+ One or more initial states
2403
+ </p>
2404
+ </div>
2405
+ </li>
2406
+
2407
+ <li>
2408
+ <span class="name">:to</span>
2409
+ <span class="type">(<tt>Symbol</tt>)</span>
2410
+ <span class="default">
2411
+
2412
+ </span>
2413
+ &mdash; <div class='inline'><p>
2414
+ One or more target states
2415
+ </p>
2416
+ </div>
2417
+ </li>
2418
+
2419
+ <li>
2420
+ <span class="name">:on</span>
2421
+ <span class="type">(<tt>Symbol</tt>)</span>
2422
+ <span class="default">
2423
+
2424
+ </span>
2425
+ &mdash; <div class='inline'><p>
2426
+ One or more events that fire the transition
2427
+ </p>
2428
+ </div>
2429
+ </li>
2430
+
2431
+ <li>
2432
+ <span class="name">:guard</span>
2433
+ <span class="type">(<tt>Boolean</tt>)</span>
2434
+ <span class="default">
2435
+
2436
+ </span>
2437
+ &mdash; <div class='inline'><p>
2438
+ Whether to guard transitions with conditionals
2439
+ </p>
2440
+ </div>
2441
+ </li>
2442
+
2443
+ </ul>
2444
+
2445
+
2446
+ <h3>Returns:</h3>
2447
+ <ul class="return">
2448
+
2449
+ <li>
2450
+
2451
+
2452
+ <span class='type'>(<tt>Array&lt;StateMachine::Transition&gt;</tt>)</span>
2453
+
2454
+
2455
+
2456
+ &mdash;
2457
+ <div class='inline'><p>
2458
+ The available transitions
2459
+ </p>
2460
+ </div>
2461
+
2462
+ </li>
2463
+
2464
+ </ul>
2465
+
2466
+ </div><table class="source_code">
2467
+ <tr>
2468
+ <td>
2469
+ <pre class="lines">
2470
+
2471
+
2472
+ 4
2473
+ 5
2474
+ 6
2475
+ 7
2476
+ 8
2477
+ 9
2478
+ 10
2479
+ 11
2480
+ 12</pre>
2481
+ </td>
2482
+ <td>
2483
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2484
+
2485
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2486
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2487
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2488
+ <span class='kw'>end</span>
2489
+
2490
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2491
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2492
+ <span class='kw'>end</span>
2493
+ <span class='kw'>end</span></pre>
2494
+ </td>
2495
+ </tr>
2496
+ </table>
2497
+ </div>
2498
+
2499
+ <div class="method_details ">
2500
+ <p class="signature " id="tow_vehicle-instance_method">
2501
+
2502
+ - (<tt>Boolean</tt>) <strong>tow_vehicle</strong>(*args)
2503
+
2504
+
2505
+
2506
+ </p><div class="docstring">
2507
+ <div class="discussion">
2508
+ <p>
2509
+ Fires the :tow_vehicle event.
2510
+ </p>
2511
+
2512
+
2513
+ </div>
2514
+ </div>
2515
+ <div class="tags">
2516
+ <h3>Parameters:</h3>
2517
+ <ul class="param">
2518
+
2519
+ <li>
2520
+
2521
+ <span class='name'>args</span>
2522
+
2523
+
2524
+ <span class='type'>(<tt>Array</tt>)</span>
2525
+
2526
+
2527
+
2528
+ &mdash;
2529
+ <div class='inline'><p>
2530
+ Optional arguments to include in transition callbacks
2531
+ </p>
2532
+ </div>
2533
+
2534
+ </li>
2535
+
2536
+ </ul>
2537
+
2538
+ <h3>Returns:</h3>
2539
+ <ul class="return">
2540
+
2541
+ <li>
2542
+
2543
+
2544
+ <span class='type'>(<tt>Boolean</tt>)</span>
2545
+
2546
+
2547
+
2548
+ &mdash;
2549
+ <div class='inline'><p>
2550
+ <tt>true</tt> if the transition succeeds, otherwise <tt>false</tt>
2551
+ </p>
2552
+ </div>
2553
+
2554
+ </li>
2555
+
2556
+ </ul>
2557
+
2558
+ </div><table class="source_code">
2559
+ <tr>
2560
+ <td>
2561
+ <pre class="lines">
2562
+
2563
+
2564
+ 4
2565
+ 5
2566
+ 6
2567
+ 7
2568
+ 8
2569
+ 9
2570
+ 10
2571
+ 11
2572
+ 12</pre>
2573
+ </td>
2574
+ <td>
2575
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2576
+
2577
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2578
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2579
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2580
+ <span class='kw'>end</span>
2581
+
2582
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2583
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2584
+ <span class='kw'>end</span>
2585
+ <span class='kw'>end</span></pre>
2586
+ </td>
2587
+ </tr>
2588
+ </table>
2589
+ </div>
2590
+
2591
+ <div class="method_details ">
2592
+ <p class="signature " id="tow_vehicle!-instance_method">
2593
+
2594
+ - (<tt>Boolean</tt>) <strong>tow_vehicle!</strong>(*args)
2595
+
2596
+
2597
+
2598
+ </p><div class="docstring">
2599
+ <div class="discussion">
2600
+ <p>
2601
+ Fires the :tow_vehicle event, raising an exception if it fails.
2602
+ </p>
2603
+
2604
+
2605
+ </div>
2606
+ </div>
2607
+ <div class="tags">
2608
+ <h3>Parameters:</h3>
2609
+ <ul class="param">
2610
+
2611
+ <li>
2612
+
2613
+ <span class='name'>args</span>
2614
+
2615
+
2616
+ <span class='type'>(<tt>Array</tt>)</span>
2617
+
2618
+
2619
+
2620
+ &mdash;
2621
+ <div class='inline'><p>
2622
+ Optional arguments to include in transition callbacks
2623
+ </p>
2624
+ </div>
2625
+
2626
+ </li>
2627
+
2628
+ </ul>
2629
+
2630
+ <h3>Returns:</h3>
2631
+ <ul class="return">
2632
+
2633
+ <li>
2634
+
2635
+
2636
+ <span class='type'>(<tt>Boolean</tt>)</span>
2637
+
2638
+
2639
+
2640
+ &mdash;
2641
+ <div class='inline'><p>
2642
+ <tt>true</tt> if the transition succeeds
2643
+ </p>
2644
+ </div>
2645
+
2646
+ </li>
2647
+
2648
+ </ul>
2649
+ <h3>Raises:</h3>
2650
+ <ul class="raise">
2651
+
2652
+ <li>
2653
+
2654
+
2655
+ <span class='type'>(<tt>StateMachine::InvalidTransition</tt>)</span>
2656
+
2657
+
2658
+
2659
+ &mdash;
2660
+ <div class='inline'><p>
2661
+ If the transition fails
2662
+ </p>
2663
+ </div>
2664
+
2665
+ </li>
2666
+
2667
+ </ul>
2668
+
2669
+ </div><table class="source_code">
2670
+ <tr>
2671
+ <td>
2672
+ <pre class="lines">
2673
+
2674
+
2675
+ 4
2676
+ 5
2677
+ 6
2678
+ 7
2679
+ 8
2680
+ 9
2681
+ 10
2682
+ 11
2683
+ 12</pre>
2684
+ </td>
2685
+ <td>
2686
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2687
+
2688
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2689
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2690
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2691
+ <span class='kw'>end</span>
2692
+
2693
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2694
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2695
+ <span class='kw'>end</span>
2696
+ <span class='kw'>end</span></pre>
2697
+ </td>
2698
+ </tr>
2699
+ </table>
2700
+ </div>
2701
+
2702
+ <div class="method_details ">
2703
+ <p class="signature " id="tow_vehicle_transition-instance_method">
2704
+
2705
+ - (<tt>StateMachine::Transition</tt>) <strong>tow_vehicle_transition</strong>(requirements = {})
2706
+
2707
+
2708
+
2709
+ </p><div class="docstring">
2710
+ <div class="discussion">
2711
+ <p>
2712
+ Gets the next transition that would be performed if :tow_vehicle were to be
2713
+ fired.
2714
+ </p>
2715
+
2716
+
2717
+ </div>
2718
+ </div>
2719
+ <div class="tags">
2720
+ <h3>Parameters:</h3>
2721
+ <ul class="param">
2722
+
2723
+ <li>
2724
+
2725
+ <span class='name'>requirements</span>
2726
+
2727
+
2728
+ <span class='type'>(<tt>Hash</tt>)</span>
2729
+
2730
+
2731
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2732
+
2733
+
2734
+ &mdash;
2735
+ <div class='inline'><p>
2736
+ The transition requirements to test against
2737
+ </p>
2738
+ </div>
2739
+
2740
+ </li>
2741
+
2742
+ </ul>
2743
+
2744
+
2745
+
2746
+
2747
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
2748
+ <ul class="option">
2749
+
2750
+ <li>
2751
+ <span class="name">:from</span>
2752
+ <span class="type">(<tt>Symbol</tt>)</span>
2753
+ <span class="default">
2754
+
2755
+ &mdash; default:
2756
+ <tt>the current state</tt>
2757
+
2758
+ </span>
2759
+ &mdash; <div class='inline'><p>
2760
+ One or more initial states
2761
+ </p>
2762
+ </div>
2763
+ </li>
2764
+
2765
+ <li>
2766
+ <span class="name">:to</span>
2767
+ <span class="type">(<tt>Symbol</tt>)</span>
2768
+ <span class="default">
2769
+
2770
+ </span>
2771
+ &mdash; <div class='inline'><p>
2772
+ One or more target states
2773
+ </p>
2774
+ </div>
2775
+ </li>
2776
+
2777
+ <li>
2778
+ <span class="name">:guard</span>
2779
+ <span class="type">(<tt>Boolean</tt>)</span>
2780
+ <span class="default">
2781
+
2782
+ </span>
2783
+ &mdash; <div class='inline'><p>
2784
+ Whether to guard transitions with conditionals
2785
+ </p>
2786
+ </div>
2787
+ </li>
2788
+
2789
+ </ul>
2790
+
2791
+
2792
+ <h3>Returns:</h3>
2793
+ <ul class="return">
2794
+
2795
+ <li>
2796
+
2797
+
2798
+ <span class='type'>(<tt>StateMachine::Transition</tt>)</span>
2799
+
2800
+
2801
+
2802
+ &mdash;
2803
+ <div class='inline'><p>
2804
+ The transition that would be performed or <tt>nil</tt>
2805
+ </p>
2806
+ </div>
2807
+
2808
+ </li>
2809
+
2810
+ </ul>
2811
+
2812
+ </div><table class="source_code">
2813
+ <tr>
2814
+ <td>
2815
+ <pre class="lines">
2816
+
2817
+
2818
+ 4
2819
+ 5
2820
+ 6
2821
+ 7
2822
+ 8
2823
+ 9
2824
+ 10
2825
+ 11
2826
+ 12</pre>
2827
+ </td>
2828
+ <td>
2829
+ <pre class="code"><span class="info file"># File 'auto_shop.rb', line 4</span>
2830
+
2831
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span> <span class='kw'>do</span>
2832
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:tow_vehicle</span> <span class='kw'>do</span>
2833
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:available</span> <span class='op'>=&gt;</span> <span class='symbol'>:busy</span>
2834
+ <span class='kw'>end</span>
2835
+
2836
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:fix_vehicle</span> <span class='kw'>do</span>
2837
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:busy</span> <span class='op'>=&gt;</span> <span class='symbol'>:available</span>
2838
+ <span class='kw'>end</span>
2839
+ <span class='kw'>end</span></pre>
2840
+ </td>
2841
+ </tr>
2842
+ </table>
2843
+ </div>
2844
+
2845
+ </div>
2846
+
2847
+ </div>
2848
+
2849
+ <div id="footer">
2850
+ Generated on Fri Feb 17 08:30:35 2012 by
2851
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2852
+ 0.7.5 (ruby-1.9.2).
2853
+ </div>
2854
+
2855
+ </body>
2856
+ </html>