class WebMinion::CycleChecker
Attributes
actions[RW]
checked[RW]
cyclical[RW]
on_stack[RW]
starting_action[RW]
Public Class Methods
new(starting_action)
click to toggle source
# File lib/web_minion/cycle_checker.rb, line 5 def initialize(starting_action) @checked = [] @on_stack = [] @starting_action = starting_action @cyclical = false check_for_cycle(starting_action) end
Public Instance Methods
cycle?()
click to toggle source
# File lib/web_minion/cycle_checker.rb, line 13 def cycle? @cyclical && !@cyclical.nil? end
Private Instance Methods
check_for_cycle(action)
click to toggle source
# File lib/web_minion/cycle_checker.rb, line 19 def check_for_cycle(action) @checked << action @on_stack << action action.next_actions.each do |act| if !@checked.include?(act) check_for_cycle(act) elsif @on_stack.include?(act) @cyclical = true return nil end end @on_stack.delete(action) end