Module: ErrorStalker::Plugin::LighthouseReporter::Actions

Defined in:
lib/error_stalker/plugin/lighthouse_reporter.rb

Overview

Extra actions that will be added to the ErrorStalker::Server instance when this plugin is enabled. Provides actions for creating a new Lighthouse ticket with exception details and posting the ticket to Lighthouse. This module also adds a lighthouse accessor to the server instance that can be used to build and send tickets to Lighthouse.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Adds the actions described above to the ErrorStalker::Server instance.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 72

def self.included(base)
  base.class_eval do

    attr_accessor :lighthouse

    get '/lighthouse/report/:id.html' do
      @exception = store.find(params["id"])
      @ticket = lighthouse.new_ticket(request, @exception)
      erb File.read(File.expand_path('views/report.erb', File.dirname(__FILE__)))
    end

    post '/lighthouse/report/:id.html' do
      if lighthouse.post_ticket(params)
        redirect "/exceptions/#{params[:id]}.html"
      else
        @error = "There was an error submitting the ticket: <br />#{@ticket.errors.join("<br />")}"
        erb File.read(File.expand_path('views/report.erb', File.dirname(__FILE__)))
      end
    end
  end
end