Class: Moose::Inventory::Operations::InventorySnapshotPreview

Inherits:
Object
  • Object
show all
Defined in:
lib/moose_inventory/operations/inventory_snapshot_preview.rb

Overview

Builds a non-mutating preview/diff for an already-validated inventory snapshot. rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(context:) ⇒ InventorySnapshotPreview

Returns a new instance of InventorySnapshotPreview.



9
10
11
# File 'lib/moose_inventory/operations/inventory_snapshot_preview.rb', line 9

def initialize(context:)
  @context = context
end

Instance Method Details

#call(snapshot:) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/moose_inventory/operations/inventory_snapshot_preview.rb', line 13

def call(snapshot:)
  preview = empty_preview
  preview_existing_entities(snapshot, preview)
  preview_group_payloads(snapshot.fetch('groups'), preview)
  preview_host_payloads(snapshot.fetch('hosts'), preview)
  preview_ignored_existing(snapshot, preview)
  preview
end