Sha256: 29bb160e190d208d146656fd4c7d87961fa5632967fe12b816382b491f2cc131

Contents?: true

Size: 672 Bytes

Versions: 11

Compression:

Stored size: 672 Bytes

Contents

require "sentry/breadcrumb"

module Sentry
  class BreadcrumbBuffer
    include Enumerable

    attr_accessor :buffer

    def initialize(size = 100)
      @buffer = Array.new(size)
    end

    def record(crumb)
      yield(crumb) if block_given?
      @buffer.slice!(0)
      @buffer << crumb
    end

    def members
      @buffer.compact
    end

    def peek
      members.last
    end

    def each(&block)
      members.each(&block)
    end

    def empty?
      members.none?
    end

    def to_hash
      {
        :values => members.map(&:to_hash)
      }
    end

    def dup
      copy = super
      copy.buffer = buffer.deep_dup
      copy
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
sentry-ruby-core-4.1.5 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.1.5.pre.beta.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.1.5.pre.beta.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.1.4 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.1.3 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.1.2 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.1.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.1.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.0.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-4.0.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-0.3.0 lib/sentry/breadcrumb_buffer.rb