transitions 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_record/transitions.rb +10 -1
- data/lib/transitions/version.rb +1 -1
- metadata +4 -4
@@ -28,12 +28,14 @@ module ActiveRecord
|
|
28
28
|
include ::Transitions
|
29
29
|
before_validation :set_initial_state
|
30
30
|
validates_presence_of :state
|
31
|
+
validate :state_inclusion
|
31
32
|
end
|
32
33
|
|
33
34
|
protected
|
34
35
|
|
35
36
|
def write_state(state_machine, state)
|
36
|
-
|
37
|
+
self.state = state.to_s
|
38
|
+
save!
|
37
39
|
end
|
38
40
|
|
39
41
|
def read_state(state_machine)
|
@@ -43,5 +45,12 @@ module ActiveRecord
|
|
43
45
|
def set_initial_state
|
44
46
|
self.state ||= self.class.state_machine.initial_state.to_s
|
45
47
|
end
|
48
|
+
|
49
|
+
def state_inclusion
|
50
|
+
unless self.class.state_machine.states.map{|s| s.name.to_s }.include?(self.state.to_s)
|
51
|
+
self.errors.add(:state, :inclusion, :value => self.state)
|
52
|
+
end
|
53
|
+
end
|
46
54
|
end
|
47
55
|
end
|
56
|
+
|
data/lib/transitions/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transitions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jakub Ku\xC5\xBAma"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-08-12 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|