Sha256: 597d06fec35ea8602b367069e79bc20251a1d838939832e0c6ee965b1f6cd8e9
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module ActiveAudit module Auditable extend ActiveSupport::Concern included do has_many :audits, as: :auditable attr_accessor :audit_comment, :audit_remote_ip, :audit_remote_uuid, :audit_source before_validation :set_audit_source!, if: -> (obj) { obj.audit_source.nil? } before_destroy :set_audit_source!, if: -> (obj) { obj.audit_source.nil? } end private def audit_params { auditable: self, user: ActiveAudit.configuration.auditor, source: audit_source, revisions: changes, comment: audit_comment, remote_ip: audit_remote_ip, remote_uuid: audit_remote_uuid } end def set_audit_source! self.audit_source = ActiveAudit.configuration.source end def trigger_audit_create! Audit.create!(audit_params.merge({ action: :create })) end def trigger_audit_update! Audit.create!(audit_params.merge({ action: :update })) end def trigger_audit_destroy! Audit.create!(audit_params.merge({ action: :destroy })) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_audit-1.0.0 | lib/active_audit/auditable.rb |
active_audit-0.1.0 | lib/active_audit/auditable.rb |