Class: Dragnet::Exporters::Serializers::VerificationResultSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/dragnet/exporters/serializers/verification_result_serializer.rb

Overview

Serializes a VerificationResult object into a Hash.

Constant Summary collapse

DATE_FORMAT =

Format used to serialize the VerificationResult's date/time attributes.

'%F %T %z'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verification_result) ⇒ VerificationResultSerializer

Returns a new instance of VerificationResultSerializer.

Parameters:



15
16
17
# File 'lib/dragnet/exporters/serializers/verification_result_serializer.rb', line 15

def initialize(verification_result)
  @verification_result = verification_result
end

Instance Attribute Details

#verification_resultObject (readonly)

Returns the value of attribute verification_result.



8
9
10
# File 'lib/dragnet/exporters/serializers/verification_result_serializer.rb', line 8

def verification_result
  @verification_result
end

Instance Method Details

#serializeHash

Returns The Hash representation of the given VerificationResult object.

Returns:

  • (Hash)

    The Hash representation of the given VerificationResult object.



21
22
23
24
25
26
27
28
29
30
# File 'lib/dragnet/exporters/serializers/verification_result_serializer.rb', line 21

def serialize
  {
    status: verification_result.status,
    started_at: verification_result.started_at.strftime(DATE_FORMAT),
    finished_at: verification_result.finished_at.strftime(DATE_FORMAT),
    runtime: verification_result.runtime
  }.tap do |hash|
    hash[:reason] = verification_result.reason if verification_result.reason
  end
end