Sha256: 8e0878412bf3c4e8fa989ffe4a6ee609bcf0dbd817bb767cfa403db43431f47c

Contents?: true

Size: 527 Bytes

Versions: 8

Compression:

Stored size: 527 Bytes

Contents

module Cassanity
  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 = {})
        result = if block_given?
          yield payload
        else
          nil
        end

        @events << Event.new(name, payload, result)
        result
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cassanity-0.6.0 lib/cassanity/instrumenters/memory.rb
cassanity-0.6.0.beta5 lib/cassanity/instrumenters/memory.rb
cassanity-0.6.0.beta4 lib/cassanity/instrumenters/memory.rb
cassanity-0.6.0.beta3 lib/cassanity/instrumenters/memory.rb
cassanity-0.6.0.beta2 lib/cassanity/instrumenters/memory.rb
cassanity-0.6.0.beta1 lib/cassanity/instrumenters/memory.rb
cassanity-0.5.1 lib/cassanity/instrumenters/memory.rb
cassanity-0.5.0 lib/cassanity/instrumenters/memory.rb