Sha256: 499685b5b3324d187a5859467c96c177bda848e27aa45cb99c5c3e1b86e3b062

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

module Stenotype
  module Adapters
    class TestAdapter < Base
      attr_reader :buffer

      def initialize(*_)
        @buffer = Array.new
        super()
      end

      #
      # @param event_data {Sting} The data to be published
      # @param additional_attrs {Hash} The list of additional event attributes
      #
      def publish(event_data, **additional_attrs)
        buffer << parse(event_data)
      end

      #
      # Clears the buffer
      #
      def flush!
        buffer.clear
      end

      private

      def parse(event_data)
        JSON.parse(event_data)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stenotype-0.1.19 lib/stenotype/adapters/test_adapter.rb
stenotype-0.1.17 lib/stenotype/adapters/test_adapter.rb
stenotype-0.1.16 lib/stenotype/adapters/test_adapter.rb