Class: Bugno::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/bugno/handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Handler

Returns a new instance of Handler.



10
11
12
13
14
# File 'lib/bugno/handler.rb', line 10

def initialize(options = {})
  @exception = options[:exception]
  @event = Event.new(exception: options[:exception], env: options[:env], job: options[:job])
  @reporter = Reporter.new
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/bugno/handler.rb', line 8

def env
  @env
end

#eventObject (readonly)

Returns the value of attribute event.



8
9
10
# File 'lib/bugno/handler.rb', line 8

def event
  @event
end

#exceptionObject (readonly)

Returns the value of attribute exception.



8
9
10
# File 'lib/bugno/handler.rb', line 8

def exception
  @exception
end

#jobObject (readonly)

Returns the value of attribute job.



8
9
10
# File 'lib/bugno/handler.rb', line 8

def job
  @job
end

#reporterObject (readonly)

Returns the value of attribute reporter.



8
9
10
# File 'lib/bugno/handler.rb', line 8

def reporter
  @reporter
end

Class Method Details

.call(options = {}) ⇒ Object



16
17
18
# File 'lib/bugno/handler.rb', line 16

def self.call(options = {})
  self.new(options).handle_exception
end

Instance Method Details

#handle_exceptionObject



20
21
22
23
24
25
# File 'lib/bugno/handler.rb', line 20

def handle_exception
  return if excluded_exception? || !usage_environment?

  @reporter.request.body = @event.data.to_json
  Bugno.configuration.send_in_background ? Thread.new { @reporter.send } : @reporter.send
end