Sha256: 95e6a6b160fd4f49a3a528dd9e4619872974f0a0380e3bcf78106e5b54fadf1a

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true

module LightServiceExt
  class Configuration
    include ActiveSupport::Configurable

    config_accessor(:allow_raise_on_failure) { true }
    config_accessor(:non_fatal_error_classes) { [] }
    config_accessor(:default_non_fatal_error_classes) { ['Rails::ActiveRecordError'.safe_constantize] }
    config_accessor(:on_raised_error) { proc {|_ctx, _error|} }

    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

3 entries across 3 versions & 1 rubygems

Version Path
light-service-ext-0.1.11 lib/light-service-ext/configuration.rb
light-service-ext-0.1.10 lib/light-service-ext/configuration.rb
light-service-ext-0.1.9 lib/light-service-ext/configuration.rb