acts_as_living 0.1.9 → 0.1.14
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: 73d33885449af7caca352c2349ec8bb1897f01b6b3d6906b8dd414d4dda6d6c9
|
4
|
+
data.tar.gz: e8fc368946103d716e0c84132f9f84662f21ddbf392237de7f2309801c8f0f9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fca0d7f19165ac60768f58cb92c29f516b7746a8078fcadfb13176d5b7899d3a5acfe8018f638a0ea31256e89cbc24075aee378f4df5f33a0e9c7365612d05e
|
7
|
+
data.tar.gz: 07e876c5194830496f4bccbd9a6e849e59d102bc7607105152acbe01e197a6978f0194a2c1071f797a5b130bfb8e2ea5b6eda041d2ba2df863e50063382b3d73
|
data/Changelog.md
CHANGED
@@ -13,3 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
13
13
|
## [0.1.7] - 2020-07-13
|
14
14
|
### Fixed
|
15
15
|
- Stage Scopes
|
16
|
+
|
17
|
+
|
18
|
+
## [0.1.10] - 2020-07-13
|
19
|
+
### Fixed
|
20
|
+
- Bugs in phase scopes
|
21
|
+
|
22
|
+
|
23
|
+
## [0.1.13] - 2020-07-13
|
24
|
+
### Fixed
|
25
|
+
- fix SQL query for phases
|
@@ -16,8 +16,9 @@ module ActsAsLiving::ActsAsLiving
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run_definers
|
19
|
-
|
19
|
+
# needs to be imported first
|
20
20
|
ActsAsLiving::MethodsDefiner.call(self)
|
21
|
+
ActsAsLiving::EnumDefiner.call(self)
|
21
22
|
ActsAsLiving::ScopesDefiner.call(self)
|
22
23
|
ActsAsLiving::ValidationsDefiner.call(self)
|
23
24
|
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?
|
@@ -105,7 +105,7 @@ module ActsAsLiving::MethodsDefiner
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def stage_keys
|
108
|
-
|
108
|
+
@stage_keys
|
109
109
|
end
|
110
110
|
|
111
111
|
def stages_after(stage)
|
@@ -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,38 +129,38 @@ 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
|
-
|
146
|
+
def first_stage_stage
|
147
|
+
(stage_keys - %i[cancelled]).first
|
148
148
|
end
|
149
149
|
|
150
|
-
def
|
151
|
-
|
150
|
+
def first_stage?(stage)
|
151
|
+
first_stage_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
|
159
|
-
|
159
|
+
phases.map(&method(:to_phase_with_range)).to_h
|
160
160
|
end
|
161
161
|
|
162
162
|
def to_phase_with_range(phase, delimiter)
|
163
|
-
[phase, (
|
163
|
+
[phase, (stages_enum[delimiter.first]..stages_enum[delimiter.last])]
|
164
164
|
end
|
165
165
|
|
166
166
|
def phases
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module ActsAsLiving::ScopesDefiner
|
2
2
|
def self.call(klass)
|
3
3
|
klass.class_eval do
|
4
|
-
|
4
|
+
stage_keys.each do |stage|
|
5
5
|
scope "past_#{stage}", -> { where('stage >= ?', stages_enum[stage]) }
|
6
6
|
scope "pre_#{stage}", -> { where('stage < ?', stages_enum[stage]) }
|
7
7
|
end
|
8
8
|
|
9
9
|
scope :cancelled, -> { where('stage < 0') }
|
10
10
|
|
11
|
-
phases.each do |phase,
|
11
|
+
phases.each do |phase, phase_stages|
|
12
12
|
scope phase, lambda {
|
13
|
-
|
13
|
+
phase_stages_integers = phase_stages.map { |stage| stages_enum[stage] }
|
14
|
+
where(stage: phase_stages_integers)
|
14
15
|
}
|
15
16
|
end
|
16
17
|
end
|