Skip to content

Commit

Permalink
Change to better express intention.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Jul 22, 2015
1 parent afcca1e commit 74021e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/finite_machine/events_chain.rb
Expand Up @@ -78,7 +78,8 @@ def find_transition(name, *conditions)
end
end

# Examine choice transitions to find one matching condition
# Examine transitions for event name that start in from state
# and find one matching condition.
#
# @param [Symbol] name
# the event name
Expand All @@ -90,10 +91,10 @@ def find_transition(name, *conditions)
# The choice transition that matches
#
# @api public
def select_choice_transition(name, from_state, *args, &block)
def transition_from(name, from_state, *conditions, &block)
chain[name].find do |trans|
[ANY_STATE, from_state].include?(trans.from_state) &&
trans.check_conditions(*args, &block)
trans.check_conditions(*conditions, &block)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/finite_machine/transition.rb
Expand Up @@ -66,7 +66,7 @@ def cancelled?
# @api public
def to_state(*args)
if transition_choice?
found_trans = machine.events_chain.select_choice_transition(name, from_state, *args)
found_trans = machine.events_chain.transition_from(name, from_state, *args)

if found_trans.nil? # no choice found
from_state
Expand Down

0 comments on commit 74021e5

Please sign in to comment.