Sha256: c82a23f33a12824ed2a4393f3b8ec39c057a63e5cc3e270dd65209d1e4367e81

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

#From rails/exception_notifier 2-3-stable branch - Not yet integrated into SuperExceptionNotifier...

#This didn't belong on ExceptionNotification::Notifier and made backtraces worse.  To keep original functionality in place
#'ActionController::Base.send :include, ExceptionNotification::ConsiderLocal' or just include in your controller
module ExceptionNotification::ConsiderLocal
  module ClassMethods
    def self.included(target)
      require 'ipaddr'
      target.extend(ClassMethods)
    end
    
    def consider_local(*args)
      local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })
    end

    def local_addresses
      addresses = read_inheritable_attribute(:local_addresses)
      unless addresses
        addresses = [IPAddr.new("127.0.0.1")]
        write_inheritable_attribute(:local_addresses, addresses)
      end
      addresses
    end
  end
  
private
  
  def local_request?
    remote = IPAddr.new(request.remote_ip)
    !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
super_exception_notifier-3.1.0 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.16 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.15 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.14 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.13 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.12 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.11 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.10 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.9 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.8 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.7 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.6 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.5 lib/exception_notification/consider_local.rb
super_exception_notifier-3.0.4 lib/exception_notification/consider_local.rb