lib/simplestate/state_holder.rb in simplestate-2.0.2 vs lib/simplestate/state_holder.rb in simplestate-2.0.3

- old
+ new

@@ -2,10 +2,11 @@ attr_reader :initial_state, :state_history def initialize(initial_state:, state_history: StateHistory.new, opts: {}) @initial_state = initial_state @state_history = state_history + @state_list = StateList.new super(NullState.new) end def start @@ -30,10 +31,11 @@ def hx_size_limit state_history.hx_size_limit end private + attr_reader :state_list def leave_old_state current_state.__send__(:exit) end def enter_new_state(state) @@ -41,9 +43,13 @@ state_history << current_state.symbol current_state.__send__(:enter) end def current_state=(state) - state_obj = State.list[state] + state_obj = state_list[state] __setobj__(state_obj) + end + + def add_state(state_instance) + state_list.add state_instance end end