acts_as_living 0.1.12 → 0.1.17

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: 766149e13a944e10eae12248a3ae63eebf60bba40a479808402eb99ef209170f
4
- data.tar.gz: fc87211523a5e977c8f2c2974984cbbaa5c5980a99960da54f5e253cefc9af14
3
+ metadata.gz: 8980c57bb91eee242c77df0474a818135fb99903e23d540aed8f0e5daa666e4c
4
+ data.tar.gz: 34cfee00e11742cde4d7a49c68e22f9282ba58d7f701df218e05cde8e6646b47
5
5
  SHA512:
6
- metadata.gz: 814e49cd0c1f5fb42d9039cc7da128bcc986c7e1594b1a89bdb59211b1c6e038cb313b6bf8773c7620892883cb9faf63c26740040cc7342decedcc3fc11a408e
7
- data.tar.gz: 0b33966724c9b203df3823dfce69065b82b344601e1193893d1c27364c0d7f73bb6a09c6fdc6abef4ee4c79db9862d7a881b94f3ba4607d2df86d580af08ff2b
6
+ metadata.gz: 777d163e2a0e02ba0d479a4ecfa571dfe35347ab6abd65afd14400a53e0ba3555e4b50b37d7866fd256782de75d1190e5cd7fcbbfdd77f279709e34fbde0dec2
7
+ data.tar.gz: 5d0134a2b6c6cb0d41b691c2ffde08f9e816619eaebaf669cbfb4decca17fe6dba988181a14fa1cdf8671cc35a8b1d003eef87f9068eee53624e3380d55e8700
@@ -18,3 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
  ## [0.1.10] - 2020-07-13
19
19
  ### Fixed
20
20
  - Bugs in phase scopes
21
+
22
+
23
+ ## [0.1.13] - 2020-07-13
24
+ ### Fixed
25
+ - fix SQL query for phases
@@ -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 newborn?
56
- self.class.newborn?(stage)
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 newborn?(stage)
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 newborn?(stage)
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 final_stage
139
- stage_keys.last
138
+ def last_stage
139
+ (stage_keys - %i[cancelled]).last
140
140
  end
141
141
 
142
- def dying?(stage)
143
- final_stage == stage
142
+ def last_stage?(stage)
143
+ last_stage == stage
144
144
  end
145
145
 
146
- def newborn_stage
147
- stage_keys.first
146
+ def first_stage
147
+ (stage_keys - %i[cancelled]).first
148
148
  end
149
149
 
150
- def death
151
- @death
150
+ def first_stage?(stage)
151
+ first_stage == stage
152
152
  end
153
153
 
154
- def newborn?(stage)
155
- initial_stage == stage
154
+ def death
155
+ @death
156
156
  end
157
157
 
158
158
  def phases_with_ranges
@@ -8,9 +8,10 @@ module ActsAsLiving::ScopesDefiner
8
8
 
9
9
  scope :cancelled, -> { where('stage < 0') }
10
10
 
11
- phases.each do |phase, delimiters|
11
+ phases.each do |phase, phase_stages|
12
12
  scope phase, lambda {
13
- where(stage: delimiters)
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
@@ -1,32 +1,26 @@
1
1
  module ActsAsLiving::ValidationsDefiner
2
- def self.call(klass)
3
- klass.class_eval do
4
- include InstanceMethods
2
+ # def self.call(klass)
3
+ # klass.class_eval do
4
+ # include InstanceMethods
5
5
 
6
- validates :stage, presence: true
6
+ # validates :stage, presence: true
7
7
 
8
- validate :stage_progression, on: :update, if: :stage_changed?
9
- validate :initialized_stage, on: :create, if: :stage_changed?
10
- end
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
- def stage_progression
15
- return if stage.to_s == self.class.death.to_s || stage == stage_after(stage_was)
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
- 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
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
- errors.add(:stage, message)
24
- end
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
@@ -1,3 +1,3 @@
1
1
  module ActsAsLiving
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_living
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Andrade