lib/statemachine/builder.rb in MINT-statemachine-1.2.2 vs lib/statemachine/builder.rb in MINT-statemachine-1.2.3

- old
+ new

@@ -254,17 +254,19 @@ def initialize(id, superstate, statemachine) super statemachine @subject = Superstate.new(id, superstate, statemachine) superstate.startstate_id = id if superstate.startstate_id == nil - # small patch to support redefinition of already existing states without # loosing the already existing transformations. Used to overwrite states # with superstates. - + if not statemachine.has_state(id) + statemachine.add_state(@subject) + end s = statemachine.get_state(id) if (s) + statemachine.remove_state(@subject) s.transitions.each {|k,v| @subject.add(v) } end statemachine.add_state(@subject) @@ -318,9 +320,10 @@ attr_reader :subject def statemachine (id, &block) builder = StatemachineBuilder.new(Statemachine.new(@subject)) #builder = StatemachineBuilder.new + builder.statemachine.is_parallel = @subject if @subject.is_a? Parallelstate builder.instance_eval(&block) if block if not @subject.is_a? Parallelstate # Only reset statemachine if it's the root one. Otherwise # the inital states on_entry function would be called! builder.statemachine.reset