Sha256: bc9243711e80554cc3522297fb18a3c4bdb60474d56504ee780950bcd243b679
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 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 ignores << Proc.new 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
isolator-0.6.1 | lib/isolator/adapters/base.rb |
isolator-0.6.0 | lib/isolator/adapters/base.rb |