statemachine 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,10 @@
1
1
  = Statemachine Changelog
2
2
 
3
+ == Version 0.4.1
4
+
5
+ Simple Fixes
6
+ * Fixed priority of default transitions, self defaults first, then superstate defaults.
7
+
3
8
  == Version 0.4.0
4
9
 
5
10
  Feature enhancements
data/TODO CHANGED
@@ -1,4 +1,2 @@
1
- Specific Exceptions... so missing events can be identified.
2
-
3
1
  Maybe:
4
2
  Implement superstate endstate with automatic transition
@@ -3,7 +3,8 @@ module Statemachine
3
3
  class State #:nodoc:
4
4
 
5
5
  attr_reader :id, :statemachine, :superstate
6
- attr_accessor :entry_action, :exit_action, :default_transition
6
+ attr_accessor :entry_action, :exit_action
7
+ attr_writer :default_transition
7
8
 
8
9
  def initialize(id, superstate, state_machine)
9
10
  @id = id
@@ -20,10 +21,21 @@ module Statemachine
20
21
  return @superstate ? @transitions.merge(@superstate.transitions) : @transitions
21
22
  end
22
23
 
23
- def transition_for(event)
24
+ def non_default_transition_for(event)
24
25
  transition = @transitions[event]
25
- transition = @superstate.transition_for(event) if @superstate and not transition
26
- transition = @default_transition if not transition
26
+ transition = @superstate.non_default_transition_for(event) if @superstate and not transition
27
+ return transition
28
+ end
29
+
30
+ def default_transition
31
+ return @default_transition if @default_transition
32
+ return @superstate.default_transition if @superstate
33
+ return nil
34
+ end
35
+
36
+ def transition_for(event)
37
+ transition = non_default_transition_for(event)
38
+ transition = default_transition if not transition
27
39
  return transition
28
40
  end
29
41
 
@@ -3,7 +3,7 @@ module Statemachine
3
3
  unless defined? MAJOR
4
4
  MAJOR = 0
5
5
  MINOR = 4
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -83,5 +83,23 @@ describe "Default Transition" do
83
83
  @sm.state.should eql(:not_default_state)
84
84
  end
85
85
 
86
+ it "should use not use superstate's default before using it's own default" do
87
+ @sm = Statemachine.build do
88
+ superstate :super do
89
+ default :super_default
90
+ state :base do
91
+ default :base_default
92
+ end
93
+ end
94
+ state :super_default
95
+ state :base_default
96
+ startstate :base
97
+ end
98
+
99
+ @sm.blah
100
+ @sm.state.should eql(:base_default)
101
+ end
102
+
103
+
86
104
 
87
105
  end
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: statemachine
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.0
7
- date: 2007-05-17 00:00:00 -05:00
8
- summary: Statemachine-0.4.0 - Statemachine Library for Ruby http://statemachine.rubyforge.org/
6
+ version: 0.4.1
7
+ date: 2007-05-20 00:00:00 -07:00
8
+ summary: Statemachine-0.4.1 - Statemachine Library for Ruby http://statemachine.rubyforge.org/
9
9
  require_paths:
10
10
  - lib
11
11
  email: statemachine-devel@rubyforge.org