Sha256: 73975c9ec11ca2770b03a4f8fc84285d4e58b7b829755d5ad3bcb51848c91773
Contents?: true
Size: 921 Bytes
Versions: 1
Compression:
Stored size: 921 Bytes
Contents
module ScrubParams module Parameters extend ActiveSupport::Concern included do attr_accessor :scrubbed_keys end def scrub! self.scrubbed_keys = [] each_pair do |k, v| self[k] = scrub_value(k, v) end if scrubbed_keys.any? ActiveSupport::Notifications.instrument("scrubbed_parameters.action_controller", keys: scrubbed_keys) end self end protected def scrub_value(key, value) case value when Hash h = {} value.each do |k, v| h[k] = scrub_value(k, v) end h when Array value.map{|v| scrub_value(key, v) } when String scrubbed_value = Sanitize.clean(value) if scrubbed_value != value self.scrubbed_keys << key unless scrubbed_keys.include?(key) end scrubbed_value else value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scrub_params-0.0.2 | lib/scrub_params/parameters.rb |