Sha256: 6450a351213f00255d8605138b31886cf45d0b045fbd9f45eeb40e01b39ff147

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module LightServiceExt
  class Configuration
    include ActiveSupport::Configurable

    config_accessor(:allow_raise_on_failure, default: true)
    config_accessor(:non_fatal_error_classes, default: [])
    config_accessor(:default_non_fatal_error_classes) { ['Rails::ActiveRecordError'.safe_constantize] }
    config_accessor(:logger) { (defined? Rails.logger).nil? ? Logger.new($stdout) : Rails.logger }

    def allow_raise_on_failure?
      !!allow_raise_on_failure
    end

    def non_fatal_errors
      (default_non_fatal_error_classes + non_fatal_error_classes).compact.uniq.map(&:to_s).freeze
    end

    def fatal_error?(exception)
      !non_fatal_errors.exclude?(exception.class.name)
    end

    def non_fatal_error?(exception)
      non_fatal_errors.include?(exception.class.name)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
light-service-ext-0.1.7 lib/light-service-ext/configuration.rb
light-service-ext-0.1.6 lib/light-service-ext/configuration.rb
light-service-ext-0.1.4 lib/light-service-ext/configuration.rb
light-service-ext-0.1.3 lib/light-service-ext/configuration.rb
light-service-ext-0.1.2 lib/light-service-ext/configuration.rb