module ActiveAudit::Base
Public Instance Methods
audit(*args)
click to toggle source
# File lib/active_audit/base.rb, line 21 def audit *args options = args.extract_options!.dup options.assert_valid_keys(:type, :except, :associations, :unless) options[:type] = options[:type].to_s if options[:type] except = options[:except] ? options[:except].map(&:to_s) : [] only = if args.present? then args.map(&:to_s) else auditing_options[:only] end options[:only] = only - except if options[:associations] options[:associations] = options[:associations].map(&:to_s) stain *options[:associations] end auditing_options.update options end
auditing_options()
click to toggle source
# File lib/active_audit/base.rb, line 14 def auditing_options @auditing_options ||= { type: self.to_s.underscore, only: self.attribute_names - ActiveAudit.ignored_attributes } end
audits(options={})
click to toggle source
# File lib/active_audit/base.rb, line 51 def audits options={} AuditRepository.find_by_record self, options end
Private Instance Methods
audited?()
click to toggle source
# File lib/active_audit/base.rb, line 56 def audited? if condition = self.class.auditing_options[:unless] case condition when Symbol, String self.public_send condition when Proc condition.call self end end return true end
write_audit(event)
click to toggle source
# File lib/active_audit/base.rb, line 68 def write_audit event if audited? audit = Audit.new event, self if audit.changed? if ActiveAudit.delayed_auditing AuditPusher.perform_later Audit.serialize(audit) else AuditRepository.save(audit) end end end end