Permalink
Browse files

Fix state query methods

  • Loading branch information...
1 parent 972709d commit 529f52d966a71719e182f5b16a8b3f3e5261667d @wfarr committed May 17, 2012
Showing with 3 additions and 3 deletions.
  1. +2 −2 lib/transitions.rb
  2. +1 −1 lib/transitions/state.rb
View
@@ -58,8 +58,8 @@ def available_states(name = :default)
state_machines[name].states.map(&:name).sort_by {|x| x.to_s}
end
- def define_state_query_method(state_name)
- name = "#{state_name}?"
+ def define_state_query_method(machine_name, state_name)
+ name = "#{machine_name}_#{state_name}?"
undef_method(name) if method_defined?(name)
define_method(name) { current_state.to_s == %(#{state_name}) }
end
View
@@ -27,7 +27,7 @@ class State
def initialize(name, options = {})
@name = name
if machine = options.delete(:machine)
- machine.klass.define_state_query_method(name)
+ machine.klass.define_state_query_method(machine.name, name)
end
update(options)
end

0 comments on commit 529f52d

Please sign in to comment.