Sha256: 91ad2f74ddfb6d97ec9bb5e233cbf2c87f05a0dd1390fe3fd843c88e1f1593fa

Contents?: true

Size: 1.27 KB

Versions: 46

Compression:

Stored size: 1.27 KB

Contents

module Bugsnag::Rails
  module ControllerMethods
    def self.included(base)
      base.extend ClassMethods
    end
    
    module ClassMethods
      private      
      def before_bugsnag_notify(*methods, &block)
        _add_bugsnag_notify_callback(:before_callbacks, *methods, &block)
      end

      def after_bugsnag_notify(*methods, &block)
        _add_bugsnag_notify_callback(:after_callbacks, *methods, &block)
      end

      def _add_bugsnag_notify_callback(callback_key, *methods, &block)
        options = methods.last.is_a?(Hash) ? methods.pop : {}

        before_filter(options) do |controller|
          request_data = Bugsnag.configuration.request_data
          request_data[callback_key] ||= []

          # Set up "method symbol" callbacks
          methods.each do |method_symbol|
            request_data[callback_key] << lambda { |notification|
              controller.send(method_symbol, notification)
            }
          end

          # Set up "block" callbacks
          request_data[callback_key] << lambda { |notification|
            controller.instance_exec(notification, &block)
          } if block_given?
        end
      end
    end

    private
    def notify_bugsnag(exception, custom_data=nil)
      Bugsnag.notify(exception, custom_data)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
bugsnag-2.7.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.7.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.6.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.6.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.5.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.5.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.4.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.4.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.3.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.2.2 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.2.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.2.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.1.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.0.3 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.0.2 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.0.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-2.0.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.8.8 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.8.7 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.8.6 lib/bugsnag/rails/controller_methods.rb