stator 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/stator/integration.rb +20 -0
- data/lib/stator/machine.rb +2 -2
- data/lib/stator/model.rb +4 -0
- data/lib/stator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6975d1e52854c059916ff592dfa6aa0b6b1ca38e
|
4
|
+
data.tar.gz: 46770289d79b6b2f4632189aa2cf8e9d8b1cbb58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 538e813262272898e14939b345f5764905289dc58a56bd881a7566b2d595ea00d979febeb439243a544d647612866e9973ddbec013903419a6c318fa48712c53
|
7
|
+
data.tar.gz: fd4b003fe8dd0347e2309803b600c12630f164462f003d643fe06d32bbf15a8c327c650e261f098607924c056fc973f29dc88e1bfb8f21821303661feb070005
|
data/lib/stator/integration.rb
CHANGED
@@ -71,6 +71,26 @@ module Stator
|
|
71
71
|
true
|
72
72
|
end
|
73
73
|
|
74
|
+
def in_state_at?(state, t)
|
75
|
+
state = state.to_s
|
76
|
+
t = t.to_time
|
77
|
+
|
78
|
+
state_at = @record.send("#{state}_#{@machine.field}_at")
|
79
|
+
|
80
|
+
return false if state_at.nil?
|
81
|
+
return false if state_at > t
|
82
|
+
|
83
|
+
min_next = @machine.states.map do |s|
|
84
|
+
next if state == s
|
85
|
+
at = @record.send("#{s}_#{@machine.field}_at")
|
86
|
+
at && at >= state_at ? at : nil
|
87
|
+
end.compact.sort[0]
|
88
|
+
|
89
|
+
return true if min_next.nil?
|
90
|
+
return true if min_next >= t
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
74
94
|
|
75
95
|
protected
|
76
96
|
|
data/lib/stator/machine.rb
CHANGED
@@ -102,14 +102,14 @@ module Stator
|
|
102
102
|
|
103
103
|
def verify_state_singularity_of_transition(transition)
|
104
104
|
transition.from_states.each do |from|
|
105
|
-
if
|
105
|
+
if matching_transition(from, transition.to_state)
|
106
106
|
raise "[Stator] another transition already exists which moves #{@class_name} from #{from.inspect} to #{transition.to_state.inspect}"
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
def verify_name_singularity_of_transition(transition)
|
112
|
-
if
|
112
|
+
if @transitions.detect{|other| transition.name && transition.name == other.name }
|
113
113
|
raise "[Stator] another transition already exists with the name of #{transition.name.inspect} in the #{@class_name} class"
|
114
114
|
end
|
115
115
|
end
|
data/lib/stator/model.rb
CHANGED
data/lib/stator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|