Sha256: b71b33a771b45572e7d0437709cb6ac78683bd6be53ce4e2a4c0428cd4bfb45a
Contents?: true
Size: 643 Bytes
Versions: 19
Compression:
Stored size: 643 Bytes
Contents
# frozen_string_literal: true require 'ipaddr' module QuoVadis module IpMasking def self.included(base) base.extend ClassMethods base.before_validation :mask_ip, if: -> { QuoVadis.mask_ips } end def mask_ip self.ip = self.class.mask_ip ip end module ClassMethods # Based on Google Analytics masking # https://support.google.com/analytics/answer/2763052 def mask_ip(ip) addr = IPAddr.new ip if addr.ipv4? addr.mask(24).to_s # set last octet to 0 else addr.mask(48).to_s # set last 80 bits to 0 end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems