12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/tracer_client/changes.rb', line 12
def log_record_changes(options = {})
send :include, InstanceMethods
class_attribute :changes_logging_options
self.changes_logging_options = options.dup
i(ignore skip only).each do |k|
changes_logging_options[k] =
[changes_logging_options[k]].flatten.compact.map { |attr| attr.is_a?(Hash) ? attr.stringify_keys : attr.to_s }
end
options_on = Array.wrap(options[:on])
after_create :log_create, :if => :log_changes? if options_on.empty? || options_on.include?(:create)
if options_on.empty? || options_on.include?(:update)
before_update :log_update, :if => :log_changes?
end
after_destroy :log_destroy, :if => :log_changes? if options_on.empty? || options_on.include?(:destroy)
end
|