Class: HubStep::Internal::Instrumenter::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/hubstep/internal/instrumenter/memory.rb

Overview

A memory instrumenter to be used in to test instrumentation. This class records each instrument call in a HubStep::Internal::Instrumenter::Memory::Event instance and stores the instance in an events array.

Defined Under Namespace

Classes: Event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



20
21
22
# File 'lib/hubstep/internal/instrumenter/memory.rb', line 20

def initialize
  @events = []
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



24
25
26
# File 'lib/hubstep/internal/instrumenter/memory.rb', line 24

def events
  @events
end

Instance Method Details

#instrument(name, payload = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/hubstep/internal/instrumenter/memory.rb', line 26

def instrument(name, payload = {})
  payload = payload.dup
  result = (yield payload if block_given?)
  @events << Event.new(name, payload, result)
  result
end