Class: AuditLoggable::ChangeSet::AttributesRedactor

Inherits:
Object
  • Object
show all
Defined in:
lib/audit_loggable/change_set.rb

Constant Summary collapse

REDACTED_VALUE =
"[REDACTED]"

Instance Method Summary collapse

Constructor Details

#initialize(redacted_attributes, changes) ⇒ AttributesRedactor

Returns a new instance of AttributesRedactor.



49
50
51
52
# File 'lib/audit_loggable/change_set.rb', line 49

def initialize(redacted_attributes, changes)
  @redacted_attributes = redacted_attributes
  @changes = changes
end

Instance Method Details

#callObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/audit_loggable/change_set.rb', line 54

def call
  @redacted_attributes.each.with_object(@changes.dup) do |name, changes|
    next unless changes.key?(name)

    changes[name] =
      if changes[name].is_a? ::Array
        ::Array.new(changes[name].size, REDACTED_VALUE)
      else
        REDACTED_VALUE
      end
  end
end