Module: Journaled::AuditLog
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/journaled/audit_log.rb,
app/models/journaled/audit_log/event.rb
Defined Under Namespace
Modules: BlockedClassMethods, BlockedMethods
Classes: Config, Event
Constant Summary
collapse
- DEFAULT_EXCLUDED_CLASSES =
%w(
Delayed::Job
PaperTrail::Version
ActiveStorage::Attachment
ActiveStorage::Blob
ActiveRecord::InternalMetadata
ActiveRecord::SchemaMigration
).freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.exclude_classes! ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/journaled/audit_log.rb', line 26
def exclude_classes!
excluded_classes.each do |name|
if Rails::VERSION::MAJOR >= 6 && Rails.autoloaders.zeitwerk_enabled?
zeitwerk_exclude!(name)
else
classic_exclude!(name)
end
end
end
|
.with_snapshots ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/journaled/audit_log.rb', line 36
def with_snapshots
snapshots_enabled_was = snapshots_enabled
self.snapshots_enabled = true
yield
ensure
self.snapshots_enabled = snapshots_enabled_was
end
|
.without_audit_logging ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/journaled/audit_log.rb', line 44
def without_audit_logging
disabled_was = _disabled
self._disabled = true
yield
ensure
self._disabled = disabled_was
end
|
Instance Method Details
#_audit_log_changes ⇒ Object
205
206
207
|
# File 'lib/journaled/audit_log.rb', line 205
def _audit_log_changes
previous_changes.except(*audit_log_config.ignored_columns)
end
|
#_emit_audit_log!(database_operation) ⇒ Object
196
197
198
199
200
201
202
203
|
# File 'lib/journaled/audit_log.rb', line 196
def _emit_audit_log!(database_operation)
if audit_log_config.enabled?
event = Journaled::AuditLog::Event.new(self, database_operation, _audit_log_changes, audit_log_config.enqueue_opts)
ActiveSupport::Notifications.instrument('journaled.audit_log.journal', event: event) do
event.journal!
end
end
end
|