Class: Radar::Matchers::ClassMatcher
- Inherits:
-
Object
- Object
- Radar::Matchers::ClassMatcher
- Defined in:
- lib/radar/matchers/class_matcher.rb
Overview
A matcher which matches exceptions with a specific class.
app.config.match :class, StandardError
app.config.match :class, StandardError, :include_subclasses => true
app.config.match :class, /.*Error/
Instance Method Summary collapse
-
#initialize(klass, opts = nil) ⇒ ClassMatcher
constructor
A new instance of ClassMatcher.
- #matches?(event) ⇒ Boolean
Constructor Details
#initialize(klass, opts = nil) ⇒ ClassMatcher
Returns a new instance of ClassMatcher.
10 11 12 13 |
# File 'lib/radar/matchers/class_matcher.rb', line 10 def initialize(klass, opts=nil) @klass = klass @opts = { :include_subclasses => false }.merge(opts || {}) end |
Instance Method Details
#matches?(event) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/radar/matchers/class_matcher.rb', line 15 def matches?(event) return event.exception.class.to_s =~ @klass if @klass.is_a?(Regexp) return event.exception.class == @klass if !@opts[:include_subclasses] # Check for subclass matches current = event.exception.class while current return true if current == @klass current = current.superclass end false end |