Module: Longleaf::EventStatusTracking

Overview

Helper methods for tracking and recording the overall outcome of a preservation event.

Instance Method Summary collapse

Methods included from Logging

#initialize_logger, initialize_logger, logger, #logger

Instance Method Details

#record_failure(*args) ⇒ Object

Record a failed operation to the output and the overall status of this event.

Parameters:

  • args (Array)

    arguments to pass to logger



26
27
28
29
# File 'lib/longleaf/events/event_status_tracking.rb', line 26

def record_failure(*args)
  logger.failure(*args)
  track_failure
end

#record_success(*args) ⇒ Object

Record a successful operation to the output and the overall status of this event.

Parameters:

  • args (Array)

    arguments to pass to logger



10
11
12
13
# File 'lib/longleaf/events/event_status_tracking.rb', line 10

def record_success(*args)
  logger.success(*args)
  track_success
end

#return_statusInteger

1 indicates failure, and 2 indicates partial failure

Returns:

  • (Integer)

    the return status for this event, where 0 indicates success,



54
55
56
57
# File 'lib/longleaf/events/event_status_tracking.rb', line 54

def return_status
  @return_status = 0 if @return_status.nil?
  @return_status
end

#track_failureObject

Update the status of this action with a failure outcome.



32
33
34
35
36
37
38
# File 'lib/longleaf/events/event_status_tracking.rb', line 32

def track_failure
  if @return_status.nil? || @return_status == 1
    @return_status = 1
  else
    @return_status = 2
  end
end

#track_status(status) ⇒ Object

Update the status of this action with the provided outcome status number.

Parameters:

  • status (Integer)

    outcome status



42
43
44
45
46
47
48
49
50
# File 'lib/longleaf/events/event_status_tracking.rb', line 42

def track_status(status)
  if status == 2
    @return_status = 2
  elsif status == 0
    track_success
  elsif status == 1
    track_failure
  end
end

#track_successObject

Update the status of this action with a success outcome.



16
17
18
19
20
21
22
# File 'lib/longleaf/events/event_status_tracking.rb', line 16

def track_success
  if @return_status.nil? || @return_status == 0
    @return_status = 0
  else
    @return_status = 2
  end
end