Module: Isolator::Adapters::Base
- Defined in:
- lib/isolator/adapters/base.rb
Overview
Used as a “template” for adapters
Instance Attribute Summary collapse
-
#details_message ⇒ Object
Returns the value of attribute details_message.
-
#exception_class ⇒ Object
Returns the value of attribute exception_class.
-
#exception_message ⇒ Object
Returns the value of attribute exception_message.
Instance Method Summary collapse
- #disable! ⇒ Object
- #disabled? ⇒ Boolean
- #enable! ⇒ Object
- #enabled? ⇒ Boolean
- #ignore_if(&block) ⇒ Object
- #ignore_on?(_obj) ⇒ Boolean
- #ignored?(*args, **kwargs) ⇒ Boolean
- #ignores ⇒ Object
- #notify(backtrace, obj, *args, **kwargs) ⇒ Object
- #notify? ⇒ Boolean
- #notify_on?(obj, *args, **kwargs) ⇒ Boolean
Instance Attribute Details
#details_message ⇒ Object
Returns the value of attribute details_message.
7 8 9 |
# File 'lib/isolator/adapters/base.rb', line 7 def @details_message end |
#exception_class ⇒ Object
Returns the value of attribute exception_class.
7 8 9 |
# File 'lib/isolator/adapters/base.rb', line 7 def exception_class @exception_class end |
#exception_message ⇒ Object
Returns the value of attribute exception_message.
7 8 9 |
# File 'lib/isolator/adapters/base.rb', line 7 def @exception_message end |
Instance Method Details
#disable! ⇒ Object
9 10 11 |
# File 'lib/isolator/adapters/base.rb', line 9 def disable! @disabled = true end |
#disabled? ⇒ Boolean
21 22 23 |
# File 'lib/isolator/adapters/base.rb', line 21 def disabled? @disabled == true end |
#enable! ⇒ Object
13 14 15 |
# File 'lib/isolator/adapters/base.rb', line 13 def enable! @disabled = false end |
#enabled? ⇒ Boolean
17 18 19 |
# File 'lib/isolator/adapters/base.rb', line 17 def enabled? !disabled? end |
#ignore_if(&block) ⇒ Object
38 39 40 |
# File 'lib/isolator/adapters/base.rb', line 38 def ignore_if(&block) ignores << block end |
#ignore_on?(_obj) ⇒ Boolean
50 51 52 |
# File 'lib/isolator/adapters/base.rb', line 50 def ignore_on?(_obj) false end |
#ignored?(*args, **kwargs) ⇒ Boolean
46 47 48 |
# File 'lib/isolator/adapters/base.rb', line 46 def ignored?(*args, **kwargs) ignores.any? { |block| block.call(*args, **kwargs) } end |
#ignores ⇒ Object
42 43 44 |
# File 'lib/isolator/adapters/base.rb', line 42 def ignores @ignores ||= [] end |
#notify(backtrace, obj, *args, **kwargs) ⇒ Object
25 26 27 28 |
# File 'lib/isolator/adapters/base.rb', line 25 def notify(backtrace, obj, *args, **kwargs) return unless notify?(*args, **kwargs) Isolator.notify(exception: build_exception(obj, args, kwargs), backtrace: backtrace) end |
#notify? ⇒ Boolean
34 35 36 |
# File 'lib/isolator/adapters/base.rb', line 34 def notify?(...) enabled? && Isolator.enabled? && Isolator.within_transaction? && !ignored?(...) end |
#notify_on?(obj, *args, **kwargs) ⇒ Boolean
30 31 32 |
# File 'lib/isolator/adapters/base.rb', line 30 def notify_on?(obj, *args, **kwargs) !ignore_on?(obj) && notify?(*args, **kwargs) end |