Class: Dragnet::Exporters::Serializers::VerificationResultSerializer
- Inherits:
-
Object
- Object
- Dragnet::Exporters::Serializers::VerificationResultSerializer
- 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
-
#verification_result ⇒ Object
readonly
Returns the value of attribute verification_result.
Instance Method Summary collapse
-
#initialize(verification_result) ⇒ VerificationResultSerializer
constructor
A new instance of VerificationResultSerializer.
-
#serialize ⇒ Hash
The
Hash
representation of the givenVerificationResult
object.
Constructor Details
#initialize(verification_result) ⇒ VerificationResultSerializer
Returns a new instance of VerificationResultSerializer.
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_result ⇒ Object (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
#serialize ⇒ Hash
Returns 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 |