Class: Clickwrap::Capture::EventBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/capture/event_builder.rb

Overview

Builds one complete, unsaved event graph from already verified input. Persistence/idempotency stay in Capture because they decide whether the protected block may run; this collaborator only constructs evidence.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(policy:, manifest:, revision:, statement_snapshots:, answers:, document_versions_by_id:, request_evidence:, event_type:, root_event_id:, predecessor_event_id:, actor:, actor_reference:, actor_snapshot:, represented_party:, authority_decision:, tenant_key:, subject:, subject_key:, subject_fingerprint:, capture_channel:, authentication_context:, attribution_method:, idempotency_key:, http_request_id:, http_route_name:, reason:, statement_action_overrides:) ⇒ EventBuilder

Returns a new instance of EventBuilder.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/clickwrap/capture/event_builder.rb', line 11

def initialize(policy:, manifest:, revision:, statement_snapshots:, answers:,
               document_versions_by_id:, request_evidence:, event_type:,
               root_event_id:, predecessor_event_id:, actor:, actor_reference:,
               actor_snapshot:, represented_party:, authority_decision:, tenant_key:,
               subject:, subject_key:, subject_fingerprint:, capture_channel:,
               authentication_context:, attribution_method:, idempotency_key:,
               http_request_id:, http_route_name:, reason:, statement_action_overrides:)
  @policy = policy
  @manifest = manifest
  @revision = revision
  @statement_snapshots = statement_snapshots
  @answers = answers
  @document_versions_by_id = document_versions_by_id
  @request_evidence = request_evidence
  @event_type = event_type
  @root_event_id = root_event_id
  @predecessor_event_id = predecessor_event_id
  @actor = actor
  @actor_reference = actor_reference
  @actor_snapshot = actor_snapshot
  @represented_party = represented_party
  @authority_decision = authority_decision
  @tenant_key = tenant_key
  @subject = subject
  @subject_key = subject_key
  @subject_fingerprint = subject_fingerprint
  @capture_channel = capture_channel
  @authentication_context = authentication_context
  @attribution_method = attribution_method
  @idempotency_key = idempotency_key
  @http_request_id = http_request_id
  @http_route_name = http_route_name
  @reason = reason
  @statement_action_overrides = statement_action_overrides
end

Instance Method Details

#buildObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/clickwrap/capture/event_builder.rb', line 47

def build
  now = Clickwrap.now
  event_id = Identifier.generate(now)
  annex = build_request_evidence_annex(event_id)
  event = build_event(event_id, annex, now)

  build_statements(event, now)
  build_documents(event)

  Result.new(event: event, request_evidence_annex: annex)
end