Class: Benchmark::Memory::HeldResults::EntrySerializer

Inherits:
Serializer
  • Object
show all
Defined in:
lib/benchmark/memory/held_results/entry_serializer.rb

Overview

Serialize entrys for holding between runs.

Instance Attribute Summary

Attributes inherited from Serializer

#object

Instance Method Summary collapse

Methods inherited from Serializer

#initialize, load, #to_json

Constructor Details

This class inherits a constructor from Benchmark::Memory::HeldResults::Serializer

Instance Method Details

#load(hash) ⇒ Report::Entry

Convert a JSON hash into an Entry.

Parameters:

  • hash (Hash)

    A JSON document hash.

Returns:



15
16
17
18
19
20
21
# File 'lib/benchmark/memory/held_results/entry_serializer.rb', line 15

def load(hash)
  @object = Report::Entry.new(
    hash["item"],
    MeasurementSerializer.load(hash["measurement"])
  )
  self
end

#to_hHash

Convert the entry to a Hash.

Returns:

  • (Hash)

    The entry as a Hash.



26
27
28
29
30
31
# File 'lib/benchmark/memory/held_results/entry_serializer.rb', line 26

def to_h
  {
    :item        => object.label,
    :measurement => MeasurementSerializer.new(object.measurement).to_h,
  }
end