Class: AuditLoggable::ChangeSet::Base

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

Direct Known Subclasses

Create, Destroy, Update

Instance Method Summary collapse

Constructor Details

#initialize(model, changes_method:, ignored_attributes: [], redacted_attributes: []) ⇒ Base

Returns a new instance of Base.



69
70
71
72
73
74
75
76
77
# File 'lib/audit_loggable/change_set.rb', line 69

def initialize(model, changes_method:, ignored_attributes: [], redacted_attributes: [])
  klass = model.class
  @changes =
    model
      .public_send(changes_method)
      .yield_self { |changes| AttributesFilter.new(klass, ignored_attributes, changes).call }
      .yield_self { |changes| EnumAttributesNormalizer.new(klass, changes).call }
      .yield_self { |changes| AttributesRedactor.new(redacted_attributes, changes).call }
end