Class: Jazari::ResolvedRunbook

Inherits:
Data
  • Object
show all
Defined in:
lib/jazari/resolved_runbook.rb

Overview

Every operation returns this. Never an unsaved ActiveRecord object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state:, revision:, topic:, description:, checklist:, target_reference:, recipe:, last_run: nil, origin: nil) ⇒ ResolvedRunbook

Returns a new instance of ResolvedRunbook.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jazari/resolved_runbook.rb', line 9

def initialize(state:, revision:, topic:, description:, checklist:,
               target_reference:, recipe:, last_run: nil, origin: nil)
  items = Checklist.freeze_items(checklist)
  super(
    state: state.freeze, revision: revision, topic: topic.freeze,
    description: description.freeze, checklist: items,
    progress: Checklist.progress(items).freeze,
    target_reference: target_reference.freeze, recipe: recipe.freeze,
    last_run: last_run.freeze, origin: origin&.freeze
  )
end

Instance Attribute Details

#checklistObject (readonly)

Returns the value of attribute checklist

Returns:

  • (Object)

    the current value of checklist



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def checklist
  @checklist
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def description
  @description
end

#last_runObject (readonly)

Returns the value of attribute last_run

Returns:

  • (Object)

    the current value of last_run



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def last_run
  @last_run
end

#originObject (readonly)

Returns the value of attribute origin

Returns:

  • (Object)

    the current value of origin



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def origin
  @origin
end

#progressObject (readonly)

Returns the value of attribute progress

Returns:

  • (Object)

    the current value of progress



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def progress
  @progress
end

#recipeObject (readonly)

Returns the value of attribute recipe

Returns:

  • (Object)

    the current value of recipe



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def recipe
  @recipe
end

#revisionObject (readonly)

Returns the value of attribute revision

Returns:

  • (Object)

    the current value of revision



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def revision
  @revision
end

#stateObject (readonly)

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def state
  @state
end

#target_referenceObject (readonly)

Returns the value of attribute target_reference

Returns:

  • (Object)

    the current value of target_reference



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def target_reference
  @target_reference
end

#topicObject (readonly)

Returns the value of attribute topic

Returns:

  • (Object)

    the current value of topic



5
6
7
# File 'lib/jazari/resolved_runbook.rb', line 5

def topic
  @topic
end

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


22
# File 'lib/jazari/resolved_runbook.rb', line 22

def custom?  = state == "custom"

#default?Boolean

Returns:

  • (Boolean)


21
# File 'lib/jazari/resolved_runbook.rb', line 21

def default? = state == "default"

#diverged?Boolean

Divergence someone chose: a row that exists, with nothing claiming to have manufactured it.

Returns:

  • (Boolean)


36
# File 'lib/jazari/resolved_runbook.rb', line 36

def diverged? = custom? && origin.nil?

#inherited?Boolean

custom? answers "does a row exist", which is not the same question as "did someone decide this". A backfill materializes a row for every subject it touches, so a host reading custom? as divergence sees 100% divergence the morning after a migration and learns nothing from it.

Comparing content against the canon does not separate them either: a backfilled runbook genuinely differs, because it carries the steps the subject actually had. Only provenance can, so only provenance is asked.

Returns:

  • (Boolean)


32
# File 'lib/jazari/resolved_runbook.rb', line 32

def inherited? = custom? && !origin.nil?