lib/simplestate/state_holder.rb in simplestate-2.0.8 vs lib/simplestate/state_holder.rb in simplestate-2.0.9

- old
+ new

@@ -12,15 +12,10 @@ def start(init_state=initial_state) enter_new_state(init_state) end - def transition_to(state) - leave_old_state - enter_new_state(state) - end - # Convenience methods def current_state __getobj__ end @@ -31,25 +26,30 @@ def hx_size_limit state_history.hx_size_limit end private - attr_reader :state_list, :state_history - def leave_old_state - current_state.__send__(:exit) - end + attr_reader :state_list, :state_history + def transition_to(state) + leave_old_state + enter_new_state(state) + end - def enter_new_state(state) - self.current_state = state - state_history << current_state.symbol - current_state.__send__(:enter) - end + def leave_old_state + current_state.__send__(:exit) + end - def current_state=(state) - state_obj = state_list[state] - __setobj__(state_obj) - end + def enter_new_state(state) + self.current_state = state + state_history << current_state.symbol + current_state.__send__(:enter) + end - def add_state(state_instance) - state_list.add state_instance - end + def current_state=(state) + state_obj = state_list[state] + __setobj__(state_obj) + end + + def add_state(state_instance) + state_list.add state_instance + end end