module DatashiftJourney::StateMachines::Extensions
Public Instance Methods
current_state_index()
click to toggle source
# File lib/datashift_journey/state_machines/extensions.rb, line 26 def current_state_index state_paths.to_states.index(state_name).to_i end
next_state_name()
click to toggle source
# File lib/datashift_journey/state_machines/extensions.rb, line 30 def next_state_name transitions_for.find { |t| t.event == :skip_fwd }.try(:to_name) end
pp_state_paths()
click to toggle source
# File lib/datashift_journey/state_machines/extensions.rb, line 16 def pp_state_paths state_paths.each_with_index { |s, i| puts "Event [#{s.events[i]}] from=#{s[i].from} to=#{s[i].to}" } end
previous_state_name()
click to toggle source
# File lib/datashift_journey/state_machines/extensions.rb, line 34 def previous_state_name transitions_for.find { |t| t.event == :back }.try(:to_name) end
state_index(state)
click to toggle source
Expects a symbol Returns nil when no such state
# File lib/datashift_journey/state_machines/extensions.rb, line 22 def state_index(state) state.nil? ? nil : state_paths.to_states.index(state.to_sym).to_i end
transitions_for()
click to toggle source
# File lib/datashift_journey/state_machines/extensions.rb, line 12 def transitions_for self.class.state_machine.events.transitions_for(self) end