Skip to content

Commit

Permalink
Ensure that may_whatever? always returns either true or false
Browse files Browse the repository at this point in the history
Instead of nil if there are no possible transitions and false if one
exists but it is not allowed.
  • Loading branch information
billhorsman committed Jun 12, 2013
1 parent 70176a7 commit e58af8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/aasm/event.rb
Expand Up @@ -64,16 +64,16 @@ def update(options = {}, &block)
self
end

# Execute if test? == false, otherwise return true/false depending on whether it would fire
# Execute if test == false, otherwise return true/false depending on whether it would fire
def _fire(obj, test, to_state=nil, *args)
result = test ? false : nil
if @transitions.map(&:from).any?
transitions = @transitions.select { |t| t.from == obj.aasm_current_state }
return nil if transitions.size == 0
return result if transitions.size == 0
else
transitions = @transitions
end

result = test ? false : nil
transitions.each do |transition|
next if to_state and !Array(transition.to).include?(to_state)
if transition.perform(obj, *args)
Expand Down

0 comments on commit e58af8e

Please sign in to comment.