Module: Harbinger::Reporters

Defined in:
lib/harbinger/reporters.rb,
lib/harbinger/reporters/null_reporter.rb,
lib/harbinger/reporters/user_reporter.rb,
lib/harbinger/reporters/request_reporter.rb,
lib/harbinger/reporters/exception_reporter.rb

Defined Under Namespace

Classes: ExceptionReporter, NullReporter, RequestReporter, UserReporter

Class Method Summary collapse

Class Method Details

.find_for(context) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/harbinger/reporters.rb', line 4

def find_for(context)
  if context.respond_to?(:to_harbinger_reporter)
    context.to_harbinger_reporter
  else
    # @TODO - Handle inheritence; KeyError is not an Exception
    reporter_class_name = reporter_name_for_instance(context)
    if const_defined?(reporter_class_name)
      const_get(reporter_class_name).new(context)
    else
      NullReporter.new(context)
    end
  end
rescue StandardError
  NullReporter.new(context)
end