Class: Mxrb::OfficialMarketplace::LifecyclePlan
- Inherits:
-
Object
- Object
- Mxrb::OfficialMarketplace::LifecyclePlan
- Defined in:
- lib/mxrb/official_marketplace/lifecycle.rb
Overview
Immutable preview whose mutation is guarded by explicit apply and blockers.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#blockers ⇒ Object
readonly
Returns the value of attribute blockers.
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#installed_version ⇒ Object
readonly
Returns the value of attribute installed_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#target_version ⇒ Object
readonly
Returns the value of attribute target_version.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply! ⇒ Object
-
#initialize(action:, name:, installed_version:, target_version:, changes:, blockers:, &operation) ⇒ LifecyclePlan
constructor
rubocop:disable Metrics/ParameterLists.
-
#safe? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(action:, name:, installed_version:, target_version:, changes:, blockers:, &operation) ⇒ LifecyclePlan
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 10 def initialize(action:, name:, installed_version:, target_version:, changes:, blockers:, &operation) @action = action @name = name @installed_version = installed_version @target_version = target_version @changes = changes.freeze @blockers = blockers.freeze @operation = operation @applied = false end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def action @action end |
#blockers ⇒ Object (readonly)
Returns the value of attribute blockers.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def blockers @blockers end |
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def changes @changes end |
#installed_version ⇒ Object (readonly)
Returns the value of attribute installed_version.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def installed_version @installed_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def name @name end |
#target_version ⇒ Object (readonly)
Returns the value of attribute target_version.
7 8 9 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7 def target_version @target_version end |
Instance Method Details
#applied? ⇒ Boolean
23 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 23 def applied? = @applied |
#apply! ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 25 def apply! raise MarketplaceError, 'Marketplace lifecycle plan was already applied' if applied? raise MarketplaceError, "Marketplace lifecycle plan is blocked: #{blockers.join('; ')}" unless safe? @operation.call @applied = true self end |
#safe? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
22 |
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 22 def safe? = blockers.empty? |