lib/isolator/adapters/base.rb in isolator-0.1.0.pre2 vs lib/isolator/adapters/base.rb in isolator-0.1.0
- old
+ new
@@ -13,19 +13,38 @@
def enable!
@disabled = false
end
def enabled?
- @disabled != true
+ !disabled?
end
- def notify(backtrace)
+ def disabled?
+ @disabled == true
+ end
+
+ def notify(backtrace, *args)
+ return unless notify?(*args)
Isolator.notify(exception: build_exception, backtrace: backtrace)
end
- def notify_isolator?
- enabled? && Isolator.within_transaction?
+ 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
klass = exception_class || Isolator::UnsafeOperationError
klass.new(exception_message)
end