journaled 5.1.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/app/models/journaled/audit_log/event.rb +2 -1
- data/lib/journaled/audit_log.rb +2 -1
- data/lib/journaled/connection.rb +2 -2
- data/lib/journaled/version.rb +1 -1
- data/lib/journaled.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677d0f45ee5a62e362e5889cfee0745e6645be394617b60585302ccbf28099a0
|
4
|
+
data.tar.gz: 30c02276b17d9cfce2534f530806b2b037c42e0b3708ef0d10b194f295f09e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b5fb2a36241ea80bfe6f07965fe048e9b5f246ff71e77c61259d78f9739e41b20a3dcf669a2ab1514169c95e01d2b8e21ac885beaa943243b6abc2ad673deb
|
7
|
+
data.tar.gz: 65baecc64ef3f99fae2e45e5133ec844cf16fcaad2463b103d8d03ad95eb32de52bde0341a58c07c65a25935359e80913806d68b12cea2de74f48517ce2d177a
|
data/README.md
CHANGED
@@ -345,6 +345,15 @@ Journaled::AuditLog.with_snapshots do
|
|
345
345
|
end
|
346
346
|
```
|
347
347
|
|
348
|
+
Snapshots can also be enabled globally for all _deletion_ operations. Since
|
349
|
+
`changes` will be empty on deletion, you should consider using this if you care
|
350
|
+
about the contents of any records being deleted (and/or don't have a full audit
|
351
|
+
trail from their time of creation):
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
Journaled::AuditLog.snapshot_on_deletion = true
|
355
|
+
```
|
356
|
+
|
348
357
|
Events with snapshots will continue to populate the `changes` field, but will
|
349
358
|
additionally contain a snapshot with the full state of the user:
|
350
359
|
|
@@ -673,6 +682,14 @@ This feature can be disabled conditionally:
|
|
673
682
|
Journaled.transactional_batching_enabled = false
|
674
683
|
```
|
675
684
|
|
685
|
+
And can then be enabled via the following block:
|
686
|
+
|
687
|
+
```ruby
|
688
|
+
Journaled.with_transactional_batching do
|
689
|
+
# your code
|
690
|
+
end
|
691
|
+
```
|
692
|
+
|
676
693
|
Backwards compatibility has been included for background jobs enqueued by
|
677
694
|
version 4.0 and above, but **has been dropped for jobs emitted by versions prior
|
678
695
|
to 4.0**. (Again, be sure to upgrade only one major version at a time.)
|
@@ -58,7 +58,8 @@ module Journaled
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def snapshot
|
61
|
-
filtered_attributes if record._log_snapshot || AuditLog.snapshots_enabled
|
61
|
+
filtered_attributes if record._log_snapshot || AuditLog.snapshots_enabled ||
|
62
|
+
(database_operation == 'delete' && AuditLog.snapshot_on_deletion)
|
62
63
|
end
|
63
64
|
|
64
65
|
def actor
|
data/lib/journaled/audit_log.rb
CHANGED
@@ -18,6 +18,7 @@ module Journaled
|
|
18
18
|
mattr_accessor(:default_enqueue_opts) { {} }
|
19
19
|
mattr_accessor(:excluded_classes) { DEFAULT_EXCLUDED_CLASSES.dup }
|
20
20
|
thread_mattr_accessor(:snapshots_enabled) { false }
|
21
|
+
thread_mattr_accessor(:snapshot_on_deletion) { false }
|
21
22
|
thread_mattr_accessor(:_disabled) { false }
|
22
23
|
thread_mattr_accessor(:_force) { false }
|
23
24
|
|
@@ -82,7 +83,7 @@ module Journaled
|
|
82
83
|
|
83
84
|
def dup
|
84
85
|
super.tap do |config|
|
85
|
-
config.ignored_columns = ignored_columns.dup
|
86
|
+
config.ignored_columns = ignored_columns.dup # rubocop:disable Rails/IgnoredColumnsAssignment
|
86
87
|
config.enqueue_opts = enqueue_opts.dup
|
87
88
|
end
|
88
89
|
end
|
data/lib/journaled/connection.rb
CHANGED
@@ -2,11 +2,11 @@ module Journaled
|
|
2
2
|
module Connection
|
3
3
|
class << self
|
4
4
|
def available?
|
5
|
-
Journaled.transactional_batching_enabled && transaction_open?
|
5
|
+
Journaled.transactional_batching_enabled? && transaction_open?
|
6
6
|
end
|
7
7
|
|
8
8
|
def stage!(event)
|
9
|
-
raise TransactionSafetyError, <<~MSG unless
|
9
|
+
raise TransactionSafetyError, <<~MSG unless available?
|
10
10
|
Transaction not available! By default, journaled event batching requires an open database transaction.
|
11
11
|
MSG
|
12
12
|
|
data/lib/journaled/version.rb
CHANGED
data/lib/journaled.rb
CHANGED
@@ -16,7 +16,19 @@ module Journaled
|
|
16
16
|
mattr_accessor(:http_open_timeout) { 2 }
|
17
17
|
mattr_accessor(:http_read_timeout) { 60 }
|
18
18
|
mattr_accessor(:job_base_class_name) { 'ActiveJob::Base' }
|
19
|
-
|
19
|
+
mattr_writer(:transactional_batching_enabled) { true }
|
20
|
+
|
21
|
+
def self.transactional_batching_enabled?
|
22
|
+
Thread.current[:journaled_transactional_batching_enabled] || @@transactional_batching_enabled
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.with_transactional_batching
|
26
|
+
value_was = Thread.current[:journaled_transactional_batching_enabled]
|
27
|
+
Thread.current[:journaled_transactional_batching_enabled] = true
|
28
|
+
yield
|
29
|
+
ensure
|
30
|
+
Thread.current[:journaled_transactional_batching_enabled] = value_was
|
31
|
+
end
|
20
32
|
|
21
33
|
def self.development_or_test?
|
22
34
|
%w(development test).include?(Rails.env)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: journaled
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Lipson
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activejob
|