simple_state_machine 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
@@ -9,9 +9,11 @@ module SimpleStateMachine
|
|
9
9
|
|
10
10
|
# mark the method as an event and specify how the state should transition
|
11
11
|
def event event_name, state_transitions
|
12
|
-
state_transitions.each do |
|
13
|
-
|
14
|
-
|
12
|
+
state_transitions.each do |froms, to|
|
13
|
+
[froms].flatten.each do |from|
|
14
|
+
transition = state_machine_definition.add_transition(event_name, from, to)
|
15
|
+
state_machine_decorator(self).decorate(transition)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{simple_state_machine}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marek de Heus", "Petrik de Heus"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-14}
|
13
13
|
s.description = %q{A simple DSL to decorate existing methods with logic that guards state transitions.}
|
14
14
|
s.email = ["FIX@example.com"]
|
15
15
|
s.extra_rdoc_files = [
|
@@ -12,6 +12,7 @@ class SimpleExample
|
|
12
12
|
'event2'
|
13
13
|
end
|
14
14
|
event :event2, :state2 => :state3
|
15
|
+
event :event_with_multiple_from, [:state1, :state2] => :state3
|
15
16
|
end
|
16
17
|
|
17
18
|
class SimpleExampleWithCustomStateMethod
|
@@ -37,7 +38,7 @@ describe SimpleStateMachine do
|
|
37
38
|
|
38
39
|
describe "events" do
|
39
40
|
|
40
|
-
it "changes state" do
|
41
|
+
it "changes state if event has multiple transitions" do
|
41
42
|
example = SimpleExample.new
|
42
43
|
example.should be_state1
|
43
44
|
example.event1
|
@@ -46,6 +47,16 @@ describe SimpleStateMachine do
|
|
46
47
|
example.should be_state3
|
47
48
|
end
|
48
49
|
|
50
|
+
it "changes state if event has multiple froms" do
|
51
|
+
example = SimpleExample.new
|
52
|
+
example.event_with_multiple_from
|
53
|
+
example.should be_state3
|
54
|
+
example = SimpleExample.new 'state2'
|
55
|
+
example.should be_state2
|
56
|
+
example.event_with_multiple_from
|
57
|
+
example.should be_state3
|
58
|
+
end
|
59
|
+
|
49
60
|
it "changes state when state is a symbol instead of a string" do
|
50
61
|
example = SimpleExample.new :state1
|
51
62
|
example.state.should == :state1
|
@@ -72,7 +83,7 @@ describe SimpleStateMachine do
|
|
72
83
|
lambda { example.event2 }.should raise_error(SimpleStateMachine::Error, "You cannot 'event2' when state is 'state1'")
|
73
84
|
end
|
74
85
|
|
75
|
-
it "
|
86
|
+
it "returns what the decorated method returns" do
|
76
87
|
example = SimpleExample.new
|
77
88
|
example.event1.should == nil
|
78
89
|
example.event2.should == 'event2'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_state_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek de Heus
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-14 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|