Sha256: a611b20af5a95c024529ab5e7c214624fb1ba27877a101abdf9e72d5c6b09771

Contents?: true

Size: 1.27 KB

Versions: 21

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|
              self.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

21 entries across 21 versions & 1 rubygems

Version Path
bugsnag-1.3.2 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.3.1 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.3.0 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.18 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.17 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.16 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.15 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.14 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.13 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.12 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.11 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.10 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.9 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.8 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.7 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.6 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.5 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.4 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.3 lib/bugsnag/rails/controller_methods.rb
bugsnag-1.2.2 lib/bugsnag/rails/controller_methods.rb