Commit a9743cb2 authored by James Lopez's avatar James Lopez

add EE audit changes class

parent 76bcb1d9
module EE
module Audit
module Changes
def audit_changes(column, options = {})
return unless model.send("#{column}_changed?")
@column = column
@options = generate_options(options)
audit_event
end
protected
def model
raise NotImplementedError, "#{self} does not implement #{__method__}"
end
private
def generate_options(options)
options.tap do |options_hash|
options_hash[:column] = @column
options_hash[:action] = :update
unless options[:skip_changes]
options_hash[:from] = model.public_send("#{@column}_was")
options_hash[:to] = model.public_send("#{@column}")
end
end
end
def audit_event
AuditEventService.new(@current_user, model, @options).
for_changes.security_event
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment