Class: Kuroko2::Token
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Kuroko2::Token
- Includes:
- TableNameCustomizable
- Defined in:
- app/models/kuroko2/token.rb
Constant Summary collapse
- WORKING =
0
- FINISHED =
1
- FAILURE =
2
- WAITING =
3
- CRITICAL =
9
- STATUSES =
{ WORKING => :working, FINISHED => :finished, FAILURE => :failure, CRITICAL => :critical, WAITING => :waiting, }.freeze
Instance Method Summary collapse
- #cancelable? ⇒ Boolean
- #critical? ⇒ Boolean
- #failure? ⇒ Boolean
- #finished? ⇒ Boolean
- #mark_as_critical(error) ⇒ Object
- #mark_as_failure ⇒ Object
- #mark_as_finished ⇒ Object
- #mark_as_waiting ⇒ Object
- #mark_as_working ⇒ Object
- #status_name ⇒ Object
- #waiting? ⇒ Boolean
- #working? ⇒ Boolean
Instance Method Details
#cancelable? ⇒ Boolean
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/kuroko2/token.rb', line 80 def cancelable? case status when WORKING, WAITING children.many? && children.all? do |child| child.status == FINISHED || child.cancelable? end when FAILURE true else false end end |
#critical? ⇒ Boolean
47 48 49 |
# File 'app/models/kuroko2/token.rb', line 47 def critical? status == CRITICAL end |
#failure? ⇒ Boolean
39 40 41 |
# File 'app/models/kuroko2/token.rb', line 39 def failure? status == FAILURE end |
#finished? ⇒ Boolean
43 44 45 |
# File 'app/models/kuroko2/token.rb', line 43 def finished? status == FINISHED end |
#mark_as_critical(error) ⇒ Object
59 60 61 62 |
# File 'app/models/kuroko2/token.rb', line 59 def mark_as_critical(error) self.status = CRITICAL self. = error. end |
#mark_as_failure ⇒ Object
55 56 57 |
# File 'app/models/kuroko2/token.rb', line 55 def mark_as_failure self.status = FAILURE end |
#mark_as_finished ⇒ Object
64 65 66 |
# File 'app/models/kuroko2/token.rb', line 64 def mark_as_finished self.status = FINISHED end |
#mark_as_waiting ⇒ Object
72 73 74 |
# File 'app/models/kuroko2/token.rb', line 72 def mark_as_waiting self.status = WAITING end |
#mark_as_working ⇒ Object
68 69 70 |
# File 'app/models/kuroko2/token.rb', line 68 def mark_as_working self.status = WORKING end |
#status_name ⇒ Object
76 77 78 |
# File 'app/models/kuroko2/token.rb', line 76 def status_name STATUSES[status].to_s end |
#waiting? ⇒ Boolean
51 52 53 |
# File 'app/models/kuroko2/token.rb', line 51 def waiting? status == WAITING end |
#working? ⇒ Boolean
35 36 37 |
# File 'app/models/kuroko2/token.rb', line 35 def working? status == WORKING end |