class Bugsnag::Breadcrumbs::OnBreadcrumbCallbackList

Public Class Methods

new(configuration) click to toggle source
# File lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb, line 3
def initialize(configuration)
  @callbacks = Set.new
  @mutex = Mutex.new
  @configuration = configuration
end

Public Instance Methods

add(callback) click to toggle source

@param callback [Proc, Method, call] @return [void]

# File lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb, line 12
def add(callback)
  @mutex.synchronize do
    @callbacks.add(callback)
  end
end
call(breadcrumb) click to toggle source

@param breadcrumb [Breadcrumb] @return [void]

# File lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb, line 30
def call(breadcrumb)
  @callbacks.each do |callback|
    begin
      should_continue = callback.call(breadcrumb)
    rescue StandardError => e
      @configuration.warn("Error occurred in on_breadcrumb callback: '#{e}'")
      @configuration.warn("on_breadcrumb callback stacktrace: #{e.backtrace.inspect}")
    end

    # only stop if should_continue is explicity 'false' to allow callbacks
    # to return 'nil'
    if should_continue == false
      breadcrumb.ignore!
      break
    end
  end
end
remove(callback) click to toggle source

@param callback [Proc, Method, call] @return [void]

# File lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb, line 21
def remove(callback)
  @mutex.synchronize do
    @callbacks.delete(callback)
  end
end