Class: Mxrb::OfficialMarketplace::LifecyclePlan

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/official_marketplace/lifecycle.rb

Overview

Immutable preview whose mutation is guarded by explicit apply and blockers.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7

def action
  @action
end

#blockersObject (readonly)

Returns the value of attribute blockers.



7
8
9
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7

def blockers
  @blockers
end

#changesObject (readonly)

Returns the value of attribute changes.



7
8
9
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7

def changes
  @changes
end

#installed_versionObject (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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 7

def name
  @name
end

#target_versionObject (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

Returns:

  • (Boolean)


23
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 23

def applied? = @applied

#apply!Object

Raises:



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

Returns:

  • (Boolean)


22
# File 'lib/mxrb/official_marketplace/lifecycle.rb', line 22

def safe? = blockers.empty?