Skip to content

Commit

Permalink
Merge pull request #73 from billhorsman/may_whatever
Browse files Browse the repository at this point in the history
Ensure that may_whatever? always returns either true or false
  • Loading branch information
alto committed Jun 12, 2013
2 parents bf02c8b + e58af8e commit 9615549
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 9615549

Please sign in to comment.