Class: Environments::RecalculateAutoStopService
- Inherits:
-
Object
- Object
- Environments::RecalculateAutoStopService
- Defined in:
- app/services/environments/recalculate_auto_stop_service.rb
Instance Attribute Summary collapse
-
#deployable ⇒ Object
readonly
Returns the value of attribute deployable.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(deployable) ⇒ RecalculateAutoStopService
constructor
A new instance of RecalculateAutoStopService.
Constructor Details
#initialize(deployable) ⇒ RecalculateAutoStopService
Returns a new instance of RecalculateAutoStopService.
7 8 9 10 |
# File 'app/services/environments/recalculate_auto_stop_service.rb', line 7 def initialize(deployable) @deployable = deployable @environment = deployable.persisted_environment end |
Instance Attribute Details
#deployable ⇒ Object (readonly)
Returns the value of attribute deployable.
5 6 7 |
# File 'app/services/environments/recalculate_auto_stop_service.rb', line 5 def deployable @deployable end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'app/services/environments/recalculate_auto_stop_service.rb', line 5 def environment @environment end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/services/environments/recalculate_auto_stop_service.rb', line 12 def execute return unless can_set_auto_stop? && environment.present? auto_stop_in = deployable. auto_stop_in ||= last_successful_deployable&. if can_reset_timer? environment.update!(auto_stop_in: auto_stop_in) if auto_stop_in.present? end |