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: a9a3d707aedeaa9b4f50be9387fa7071fcfefb84781400355b7f8db379e9e586
4
- data.tar.gz: 2e14f610949e6758b521a1f8c5eac4362eeca7477d7b2db3a66c083c77540dff
3
+ metadata.gz: cf37165538490c682fd3ad0d6e95de9dd0979b79ebaa0451941138f6ad98d5a9
4
+ data.tar.gz: b92afce89dcf932c0c8c8bb568a37b440d25ccdcbfd1d2f8565e2c314d25b8bc
5
5
  SHA512:
6
- metadata.gz: 555d8a9fddc3d6c334cc0e18fd5f7e038ff2a58a6dfd4fba7ad9dc7ad734291f99ca4c79fd5dc7f44163b5645fb4744d675ddc04e32243beaf2c7a2d737c2a96
7
- data.tar.gz: ad7ff2e43e41feec0338c4118e65f4abd1f06a662b5408b804b512a3aedbc603422890b2ef9d9e53cbf192a609ad389cc3427c7e021a0ada754a21f115106025
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
@@ -5,7 +5,7 @@ module ActsAsLiving::EnumDefiner
5
5
  klass.class_eval do
6
6
  extend ClassMethods
7
7
 
8
- enum @column => stages_enum
8
+ enum stage: stages_enum
9
9
  end
10
10
  end
11
11
 
@@ -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
@@ -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.13"
2
+ VERSION = "0.1.18"
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.13
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Andrade