Sha256: 55bb7aea69f8c2abb9fdd149b25527312be4217b16371ae0ad6f8fd5da9f1148

Contents?: true

Size: 699 Bytes

Versions: 7

Compression:

Stored size: 699 Bytes

Contents

require 'active_support/concern'

module WatCatcher
  module CatcherOfWats
    extend ActiveSupport::Concern

    included do
      around_action :catch_wats

      helper_method :wat_user
    end

    def wat_user
      current_user
    end

    def disable_wat_report
      request.env["wat_report_disabled"] = true
    end

    def report_wat?
      !!(request.env["wat_report"].present? && !request.env["wat_report_disabled"])
    end

    def catch_wats(&block)
      block.call
    rescue Exception => e
      user = nil
      begin
        user = wat_user
      rescue;end
      request.env["wat_report"] = {
        request: request,
        user: user
      }
      raise
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wat_catcher-0.10.11 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.10 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.9 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.8 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.7 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.6 app/controllers/wat_catcher/catcher_of_wats.rb
wat_catcher-0.10.5 app/controllers/wat_catcher/catcher_of_wats.rb