class Flipper::Instrumenters::Memory
Instrumentor that is useful for tests as it stores each of the events that are instrumented.
Constants
- Event
Attributes
events[R]
Public Class Methods
new()
click to toggle source
# File lib/flipper/instrumenters/memory.rb, line 10 def initialize @events = [] end
Public Instance Methods
event_by_name(name)
click to toggle source
# File lib/flipper/instrumenters/memory.rb, line 29 def event_by_name(name) events_by_name(name).first end
events_by_name(name)
click to toggle source
# File lib/flipper/instrumenters/memory.rb, line 25 def events_by_name(name) @events.select { |event| event.name == name } end
instrument(name, payload = {}) { |payload| ... }
click to toggle source
# File lib/flipper/instrumenters/memory.rb, line 14 def instrument(name, payload = {}) # Copy the payload to guard against later modifications to it, and to # ensure that all instrumentation code uses the payload passed to the # block rather than the one passed to #instrument. payload = payload.dup result = (yield payload if block_given?) @events << Event.new(name, payload, result) result end
reset()
click to toggle source
# File lib/flipper/instrumenters/memory.rb, line 33 def reset @events = [] end