module StateMachinable::Model
Public Instance Methods
state_machine()
click to toggle source
# File lib/state_machinable/model.rb, line 19 def state_machine @state_machine ||= self.class.state_machine_class.new(self, :transition_class => self.class.transition_class) end
state_machine_class()
click to toggle source
# File lib/state_machinable/model.rb, line 6 def state_machine_class "#{self}StateMachine".constantize end
transition_class()
click to toggle source
# File lib/state_machinable/model.rb, line 10 def transition_class "#{self}Transition".constantize end
transition_to_initial_state()
click to toggle source
# File lib/state_machinable/model.rb, line 23 def transition_to_initial_state initial_state = self.state_machine.class.successors['initial'].first if (!self.respond_to?(:skip_state_machine?) || !self.skip_state_machine?) && (self.current_state != initial_state) self.transition_to!(self.state_machine.class.successors['initial'].first) end end