Sha256: e6a61d0ad65c4f4a4072f681ff99f94df5fcdef8084ee6ae40b17cc47c384aed

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Isolator
  # Isolator configuration:
  #
  # - `raise_exceptions` - whether to raise an exception in case of offense;
  #   defaults to true in test env and false otherwise.
  #   NOTE: env is inferred from RACK_ENV and RAILS_ENV.
  #
  # - `logger` - logger instance (nil by default)
  #
  # - `send_notifications` - whether to send notifications (through uniform_notifier);
  #   defaults to false
  #
  # - `backtrace_filter` - define a custom backtrace filtering (provide a callable)
  #
  # - `ignorer` - define a custom ignorer (must implement .prepare)
  #
  class Configuration
    attr_accessor :raise_exceptions, :logger, :send_notifications,
      :backtrace_filter, :ignorer

    def initialize
      @logger = nil
      @raise_exceptions = test_env?
      @send_notifications = false
      @backtrace_filter = ->(backtrace) { backtrace.take(5) }
      @ignorer = Isolator::Ignorer
    end

    alias_method :raise_exceptions?, :raise_exceptions
    alias_method :send_notifications?, :send_notifications

    def test_env?
      ENV["RACK_ENV"] == "test" || ENV["RAILS_ENV"] == "test"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
isolator-1.1.0 lib/isolator/configuration.rb
isolator-1.0.1 lib/isolator/configuration.rb
isolator-1.0.0 lib/isolator/configuration.rb
isolator-0.11.0 lib/isolator/configuration.rb
isolator-0.10.0 lib/isolator/configuration.rb
isolator-0.9.0 lib/isolator/configuration.rb
isolator-0.8.0 lib/isolator/configuration.rb