acts_as_living 0.1.13 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf37165538490c682fd3ad0d6e95de9dd0979b79ebaa0451941138f6ad98d5a9
|
4
|
+
data.tar.gz: b92afce89dcf932c0c8c8bb568a37b440d25ccdcbfd1d2f8565e2c314d25b8bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0decbc9e805acb68fcb27c656c8f1300b843db698b6140dc2d22b8422df8924bcd87734fed6e7e08203dd2974c512370960db2b391108f5f96cef78ae441d18d
|
7
|
+
data.tar.gz: c875f6111028033b17be042ab8ca2ff1b91d3aaabe4081b5da1f9e9ee6adf5b279b08983939892573c64879c0df20cc52a87088d43f820fc3cde750be2ba0856
|
@@ -20,7 +20,7 @@ module ActsAsLiving::ActsAsLiving
|
|
20
20
|
ActsAsLiving::MethodsDefiner.call(self)
|
21
21
|
ActsAsLiving::EnumDefiner.call(self)
|
22
22
|
ActsAsLiving::ScopesDefiner.call(self)
|
23
|
-
ActsAsLiving::ValidationsDefiner.call(self)
|
23
|
+
# ActsAsLiving::ValidationsDefiner.call(self)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -52,8 +52,8 @@ module ActsAsLiving::MethodsDefiner
|
|
52
52
|
self.class.dying?(stage)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
self.class.
|
55
|
+
def first_stage?
|
56
|
+
self.class.first_stage?(stage)
|
57
57
|
end
|
58
58
|
|
59
59
|
def dead?
|
@@ -115,7 +115,7 @@ module ActsAsLiving::MethodsDefiner
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def stages_before(stage)
|
118
|
-
return [] if
|
118
|
+
return [] if first_stage?(stage)
|
119
119
|
|
120
120
|
index = stage_keys.find_index(stage)
|
121
121
|
stage_keys[0...index]
|
@@ -129,30 +129,30 @@ module ActsAsLiving::MethodsDefiner
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def stage_before(stage)
|
132
|
-
return if
|
132
|
+
return if first_stage?(stage)
|
133
133
|
|
134
134
|
index = stage_keys.find_index(stage)
|
135
135
|
stage_keys[index - 1]
|
136
136
|
end
|
137
137
|
|
138
|
-
def
|
139
|
-
stage_keys.last
|
138
|
+
def last_stage
|
139
|
+
(stage_keys - %i[cancelled]).last
|
140
140
|
end
|
141
141
|
|
142
|
-
def
|
143
|
-
|
142
|
+
def last_stage?(stage)
|
143
|
+
last_stage == stage
|
144
144
|
end
|
145
145
|
|
146
|
-
def
|
147
|
-
stage_keys.first
|
146
|
+
def first_stage
|
147
|
+
(stage_keys - %i[cancelled]).first
|
148
148
|
end
|
149
149
|
|
150
|
-
def
|
151
|
-
|
150
|
+
def first_stage?(stage)
|
151
|
+
first_stage == stage
|
152
152
|
end
|
153
153
|
|
154
|
-
def
|
155
|
-
|
154
|
+
def death
|
155
|
+
@death
|
156
156
|
end
|
157
157
|
|
158
158
|
def phases_with_ranges
|
@@ -1,32 +1,26 @@
|
|
1
1
|
module ActsAsLiving::ValidationsDefiner
|
2
|
-
def self.call(klass)
|
3
|
-
|
4
|
-
|
2
|
+
# def self.call(klass)
|
3
|
+
# klass.class_eval do
|
4
|
+
# include InstanceMethods
|
5
5
|
|
6
|
-
|
6
|
+
# validates :stage, presence: true
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
8
|
+
# validate :stage_progression, on: :update, if: :stage_changed?
|
9
|
+
# validate :stage_is_first_stage, on: :create, if: :stage_changed?
|
10
|
+
# end
|
11
|
+
# end
|
12
12
|
|
13
|
-
module InstanceMethods
|
14
|
-
|
15
|
-
|
13
|
+
# module InstanceMethods
|
14
|
+
# def stage_progression
|
15
|
+
# return if stage.to_s == self.class.death.to_s || stage == stage_after(stage_was)
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
# message = if stage_was == self.class.final_stage
|
18
|
+
# "The contract can only be updated to '#{self.class.death}'"
|
19
|
+
# else
|
20
|
+
# "The contract can only be updated to '#{self.class.death}' or '#{stage_after(stage_was)}'"
|
21
|
+
# end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def initialized_stage
|
27
|
-
return if stage == self.class.initial_stage
|
28
|
-
|
29
|
-
errors.add(:stage, "Contract has to be initialized with '#{self.class.initial_stage}' stage")
|
30
|
-
end
|
31
|
-
end
|
23
|
+
# errors.add(:stage, message)
|
24
|
+
# end
|
25
|
+
# end
|
32
26
|
end
|