acts_as_living 0.1.8 → 0.1.13
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: a9a3d707aedeaa9b4f50be9387fa7071fcfefb84781400355b7f8db379e9e586
|
4
|
+
data.tar.gz: 2e14f610949e6758b521a1f8c5eac4362eeca7477d7b2db3a66c083c77540dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555d8a9fddc3d6c334cc0e18fd5f7e038ff2a58a6dfd4fba7ad9dc7ad734291f99ca4c79fd5dc7f44163b5645fb4744d675ddc04e32243beaf2c7a2d737c2a96
|
7
|
+
data.tar.gz: ad7ff2e43e41feec0338c4118e65f4abd1f06a662b5408b804b512a3aedbc603422890b2ef9d9e53cbf192a609ad389cc3427c7e021a0ada754a21f115106025
|
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
|
@@ -5,12 +5,12 @@ module ActsAsLiving::EnumDefiner
|
|
5
5
|
klass.class_eval do
|
6
6
|
extend ClassMethods
|
7
7
|
|
8
|
-
enum @column =>
|
8
|
+
enum @column => stages_enum
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
def
|
13
|
+
def stages_enum
|
14
14
|
stages = @stage_keys.map.with_index(&method(:to_enum_map)).to_h
|
15
15
|
stages.merge(@death => @spread * -1)
|
16
16
|
end
|
@@ -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)
|
@@ -144,7 +144,7 @@ module ActsAsLiving::MethodsDefiner
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def newborn_stage
|
147
|
-
|
147
|
+
stage_keys.first
|
148
148
|
end
|
149
149
|
|
150
150
|
def death
|
@@ -156,11 +156,11 @@ module ActsAsLiving::MethodsDefiner
|
|
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,17 +1,17 @@
|
|
1
1
|
module ActsAsLiving::ScopesDefiner
|
2
2
|
def self.call(klass)
|
3
3
|
klass.class_eval do
|
4
|
-
|
5
|
-
|
6
|
-
scope "
|
7
|
-
scope "pre_#{stage}", -> { where('stage < ?', stages[stage]) }
|
4
|
+
stage_keys.each do |stage|
|
5
|
+
scope "past_#{stage}", -> { where('stage >= ?', stages_enum[stage]) }
|
6
|
+
scope "pre_#{stage}", -> { where('stage < ?', stages_enum[stage]) }
|
8
7
|
end
|
9
8
|
|
10
9
|
scope :cancelled, -> { where('stage < 0') }
|
11
10
|
|
12
|
-
|
11
|
+
phases.each do |phase, phase_stages|
|
13
12
|
scope phase, lambda {
|
14
|
-
|
13
|
+
phase_stages_integers = phase_stages.map { |stage| stages_enum[stage] }
|
14
|
+
where(stage: phase_stages_integers)
|
15
15
|
}
|
16
16
|
end
|
17
17
|
end
|