Sha256: 0922f1e98ba02ec1dc935eb387c9a827d1b1dbfdccbb992ac7bfbf9ca3be65c2

Contents?: true

Size: 708 Bytes

Versions: 23

Compression:

Stored size: 708 Bytes

Contents

require "sentry/breadcrumb"

module Sentry
  class BreadcrumbBuffer
    DEFAULT_SIZE = 100
    include Enumerable

    attr_accessor :buffer

    def initialize(size = nil)
      @buffer = Array.new(size || DEFAULT_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

23 entries across 23 versions & 1 rubygems

Version Path
sentry-ruby-core-4.8.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.7.3 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.7.2 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.7.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.7.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.5 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.4 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.3 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.2 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.6.0.pre.beta.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.5.2 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.5.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.5.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.5.0.pre.beta.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.4.2 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.4.1 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.4.0 lib/sentry/breadcrumb_buffer.rb
sentry-ruby-core-4.4.0.pre.beta.0 lib/sentry/breadcrumb_buffer.rb