lib/stateful_enum/machine.rb in stateful_enum-0.2.0 vs lib/stateful_enum/machine.rb in stateful_enum-0.2.1
- old
+ new
@@ -2,11 +2,11 @@
class Machine
def initialize(model, column, states, &block)
@model, @column, @states, @event_names = model, column, states, []
# undef non-verb methods e.g. Model#active!
- states.each_key do |state|
+ states.each do |state|
@model.send :undef_method, "#{state}!"
end
instance_eval(&block) if block
end
@@ -63,19 +63,19 @@
if (unless_condition = transitions.delete :unless)
options[:if] = -> { !instance_exec(&unless_condition) }
end
end
transitions.each_pair do |from, to|
- raise "Undefined state #{to}" unless @states.has_key? to
+ raise "Undefined state #{to}" unless @states.include? to
Array(from).each do |f|
- raise "Undefined state #{f}" unless @states.has_key? f
+ raise "Undefined state #{f}" unless @states.include? f
@transitions[f] = [to, options[:if]]
end
end
end
def all
- @states.keys
+ @states
end
def before(&block)
@before = block
end