Sha256: 3a3b54f88fbffc3d8502f8a82473876999bd2aef4e6f17f9db495abb7d0d21c4
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Isolator module Adapters # Used as a "template" for adapters module Base attr_accessor :exception_class, :exception_message, :details_message def disable! @disabled = true end def enable! @disabled = false end def enabled? !disabled? end def disabled? @disabled == true end def notify(backtrace, obj, *args) return unless notify?(*args) Isolator.notify(exception: build_exception(obj, args), backtrace: backtrace) end def notify?(*args) enabled? && Isolator.enabled? && Isolator.within_transaction? && !ignored?(*args) end def ignore_if(&block) ignores << block end def ignores @ignores ||= [] end def ignored?(*args) ignores.any? { |block| block.call(*args) } end private def build_exception(obj, args) klass = exception_class || Isolator::UnsafeOperationError details = details_message.call(obj, args) if details_message klass.new(exception_message, details: details) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
isolator-0.8.0 | lib/isolator/adapters/base.rb |
isolator-0.7.0 | lib/isolator/adapters/base.rb |
isolator-0.6.2 | lib/isolator/adapters/base.rb |