Class: Legion::Data::Model::DigitalWorker
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Legion::Data::Model::DigitalWorker
- Defined in:
- lib/legion/data/models/digital_worker.rb
Constant Summary collapse
- LIFECYCLE_STATES =
%w[bootstrap active paused retired terminated].freeze
- CONSENT_TIERS =
%w[supervised consult notify autonomous].freeze
- RISK_TIERS =
%w[low medium high critical].freeze
- HEALTH_STATUSES =
%w[online offline unknown].freeze
Instance Method Summary collapse
- #active? ⇒ Boolean
- #offline? ⇒ Boolean
- #online? ⇒ Boolean
- #paused? ⇒ Boolean
- #terminated? ⇒ Boolean
- #validate ⇒ Object
Instance Method Details
#active? ⇒ Boolean
22 23 24 |
# File 'lib/legion/data/models/digital_worker.rb', line 22 def active? lifecycle_state == 'active' end |
#offline? ⇒ Boolean
38 39 40 |
# File 'lib/legion/data/models/digital_worker.rb', line 38 def offline? health_status == 'offline' end |
#online? ⇒ Boolean
34 35 36 |
# File 'lib/legion/data/models/digital_worker.rb', line 34 def online? health_status == 'online' end |
#paused? ⇒ Boolean
30 31 32 |
# File 'lib/legion/data/models/digital_worker.rb', line 30 def paused? lifecycle_state == 'paused' end |
#terminated? ⇒ Boolean
26 27 28 |
# File 'lib/legion/data/models/digital_worker.rb', line 26 def terminated? lifecycle_state == 'terminated' end |
#validate ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/legion/data/models/digital_worker.rb', line 14 def validate super errors.add(:lifecycle_state, 'invalid') unless LIFECYCLE_STATES.include?(lifecycle_state) errors.add(:consent_tier, 'invalid') unless CONSENT_TIERS.include?() errors.add(:risk_tier, 'invalid') if risk_tier && !RISK_TIERS.include?(risk_tier) errors.add(:health_status, 'invalid') if health_status && !HEALTH_STATUSES.include?(health_status) end |