Class: Greenroom::Reporter::Memory

Inherits:
Reporter
  • Object
show all
Defined in:
lib/greenroom/reporter.rb

Overview

Accumulates every recorded event in memory instead of sending it anywhere. Exists for tests: a spec can install this reporter and then assert on #events instead of stubbing a real delivery library.

Defined Under Namespace

Classes: Event

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



53
54
55
# File 'lib/greenroom/reporter.rb', line 53

def initialize
  @events = []
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



51
52
53
# File 'lib/greenroom/reporter.rb', line 51

def events
  @events
end

Instance Method Details

#record(event_type, attributes) ⇒ Object



57
58
59
# File 'lib/greenroom/reporter.rb', line 57

def record(event_type, attributes)
  @events << Event.new(event_type, truncate(attributes))
end