lib/micromachine.rb in soveran-micromachine-0.0.8 vs lib/micromachine.rb in soveran-micromachine-0.0.9
- old
+ new
@@ -1,6 +1,8 @@
class MicroMachine
+ InvalidEvent = Class.new(NoMethodError)
+
attr :transitions_for
attr :state
def initialize initial_state
@state = initial_state
@@ -20,7 +22,9 @@
end
end
def trigger?(event)
transitions_for[event][state]
+ rescue NoMethodError
+ raise InvalidEvent
end
end