Sha256: 71a3b7403c5bed40564f2736ee9ad8830c1130e7b73b71304461970d446da99e

Contents?: true

Size: 723 Bytes

Versions: 16

Compression:

Stored size: 723 Bytes

Contents

module Flipper
  module Instrumenters
    # Instrumentor that is useful for tests as it stores each of the events that
    # are instrumented.
    class Memory
      Event = Struct.new(:name, :payload, :result)

      attr_reader :events

      def initialize
        @events = []
      end

      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
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flipper-0.14.0 lib/flipper/instrumenters/memory.rb
flipper-0.13.0 lib/flipper/instrumenters/memory.rb
flipper-0.13.0.beta1 lib/flipper/instrumenters/memory.rb
flipper-0.12.2 lib/flipper/instrumenters/memory.rb
flipper-0.12.1 lib/flipper/instrumenters/memory.rb
flipper-0.12.0 lib/flipper/instrumenters/memory.rb
flipper-0.11.0 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.rc1 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta9 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta8 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta7 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta6 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta5 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta4 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta3 lib/flipper/instrumenters/memory.rb
flipper-0.11.0.beta1 lib/flipper/instrumenters/memory.rb