Class: WhoopsNotifier::Investigator

Inherits:
Object
  • Object
show all
Defined in:
lib/whoops_notifier/investigator.rb

Overview

A “glue” class which coordinates report creation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy, evidence) ⇒ Investigator

Returns a new instance of Investigator.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'lib/whoops_notifier/investigator.rb', line 8

def initialize(strategy, evidence)
  raise ArgumentError, "strategy can not be nil" if strategy.nil?
  raise ArgumentError, "strategy must respond to 'call'" unless strategy.respond_to?(:call)
  self.strategy = strategy
  self.evidence = evidence
  self.report = Report.new
end

Instance Attribute Details

#evidenceObject

get data from evidence using a strategy to create a report and decide whether it should be ignored



6
7
8
# File 'lib/whoops_notifier/investigator.rb', line 6

def evidence
  @evidence
end

#reportObject

get data from evidence using a strategy to create a report and decide whether it should be ignored



6
7
8
# File 'lib/whoops_notifier/investigator.rb', line 6

def report
  @report
end

#strategyObject

get data from evidence using a strategy to create a report and decide whether it should be ignored



6
7
8
# File 'lib/whoops_notifier/investigator.rb', line 6

def strategy
  @strategy
end

Instance Method Details

#ignore_report?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/whoops_notifier/investigator.rb', line 20

def ignore_report?
  report.ignore?
end

#investigate!Object



16
17
18
# File 'lib/whoops_notifier/investigator.rb', line 16

def investigate!
  strategy.call(report, evidence)
end