Class: Clickwrap::Services::PublishDocuments

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/services/publish_documents.rb

Overview

bin/rails clickwrap:publish — reads the declared document bytes once, digests them, and freezes a database snapshot.

After this runs, the snapshot is the evidence and the file on disk is only where it came from. Editing the file changes nothing about what was already published, which is exactly the property a receipt from three years ago depends on.

The task is idempotent: re-publishing identical bytes under the same label is a no-op. Re-publishing different bytes under the same label is refused, because a version label that can mean two different documents is not a version label.

Defined Under Namespace

Classes: Outcome

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dry_run: false, definitions: nil) ⇒ PublishDocuments

Returns a new instance of PublishDocuments.



24
25
26
27
# File 'lib/clickwrap/services/publish_documents.rb', line 24

def initialize(dry_run: false, definitions: nil)
  @dry_run = dry_run
  @definitions = definitions || Clickwrap.documents.values
end

Instance Attribute Details

#definitionsObject (readonly)

Returns the value of attribute definitions.



29
30
31
# File 'lib/clickwrap/services/publish_documents.rb', line 29

def definitions
  @definitions
end

#dry_runObject (readonly)

Returns the value of attribute dry_run.



29
30
31
# File 'lib/clickwrap/services/publish_documents.rb', line 29

def dry_run
  @dry_run
end

Instance Method Details

#callObject Also known as: plan



31
32
33
# File 'lib/clickwrap/services/publish_documents.rb', line 31

def call
  definitions.map { |definition| publish(definition) }
end