Sha256: b3282aa147c37898051983c678293fa914c53da8566065be4ecba396575ff71e

Contents?: true

Size: 770 Bytes

Versions: 19

Compression:

Stored size: 770 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 = if block_given?
          yield payload
        else
          nil
        end
        @events << Event.new(name, payload, result)
        result
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
flipper-0.10.2 lib/flipper/instrumenters/memory.rb
flipper-0.10.1 lib/flipper/instrumenters/memory.rb
flipper-0.10.0 lib/flipper/instrumenters/memory.rb
flipper-0.9.2 lib/flipper/instrumenters/memory.rb
flipper-0.9.1 lib/flipper/instrumenters/memory.rb
flipper-0.9.0 lib/flipper/instrumenters/memory.rb
flipper-0.9.0.beta1 lib/flipper/instrumenters/memory.rb
flipper-0.8.0 lib/flipper/instrumenters/memory.rb
flipper-0.7.5 lib/flipper/instrumenters/memory.rb
flipper-0.7.4 lib/flipper/instrumenters/memory.rb
flipper-0.7.3 lib/flipper/instrumenters/memory.rb
flipper-0.7.2 lib/flipper/instrumenters/memory.rb
flipper-0.7.1 lib/flipper/instrumenters/memory.rb
flipper-0.7.0 lib/flipper/instrumenters/memory.rb
flipper-0.7.0.beta6 lib/flipper/instrumenters/memory.rb
flipper-0.7.0.beta5 lib/flipper/instrumenters/memory.rb
flipper-0.7.0.beta4 lib/flipper/instrumenters/memory.rb
flipper-0.7.0.beta3 lib/flipper/instrumenters/memory.rb
flipper-0.7.0.beta2 lib/flipper/instrumenters/memory.rb