paper_trail-rails 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +6 -0
- data/lib/paper_trail/rails/paper_trail_extensions.rb +13 -0
- data/lib/paper_trail/rails/version.rb +1 -1
- data/lib/paper_trail/rails.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cbd2f0eda94258a20e3a294ed155191773c27af3d91bcbd66c63971084e37e8
|
4
|
+
data.tar.gz: d59ed0df5959182a653556c3583e963ef9df5d2669821f15b4ae06c2deade834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd93b66499033e9b62bb521bd0870f81fa4a4c4fbe3f4916a5359dbd5fa04279ce5a2ec8396e474062588f70db1170f0e8810293145914dd2f25539451ef298a
|
7
|
+
data.tar.gz: 2b5bd83ee674694032247fec1212dd4ce2a3f49cddaa1ce1380235e4ed3300d3eb0af7ce126942d7beee48c1213e7faf411aff4017565afce8b039206ec1af1d
|
data/Changelog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.6.1 (2023-06-15)
|
2
|
+
- Add `PaperTrail.metadata`, `PaperTrail.reverse_update_metadata`
|
3
|
+
- Change `set_default_metadata` to only set `command` to `default_command` if it hasn't been set yet. This
|
4
|
+
fixes bug where the command set by `RunnerCommandExtensions` got overwritten when the `whodunnit`
|
5
|
+
callback called `set_default_metadata` again.
|
6
|
+
|
1
7
|
## 0.6.0 (2023-06-14)
|
2
8
|
- Include the rails subcommand (`'rails console'`, etc.) in the `command` metadata, not just `'rails'`
|
3
9
|
- When using `rails runner`, include the full Ruby code/file that was run in the `command` metadata.
|
@@ -1,5 +1,11 @@
|
|
1
1
|
PaperTrail.class_eval do
|
2
2
|
|
3
|
+
unless methods.include?(:metadata)
|
4
|
+
def self.metadata
|
5
|
+
PaperTrail.request.controller_info
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
unless methods.include?(:with_metadata)
|
4
10
|
# Adds additional metadata to versions created within the given block. This will be merged with
|
5
11
|
# (and may override) any metadata already set by your controller's info_for_paper_trail.
|
@@ -27,4 +33,11 @@ PaperTrail.class_eval do
|
|
27
33
|
PaperTrail.request.controller_info = merged_metadata
|
28
34
|
end
|
29
35
|
end
|
36
|
+
|
37
|
+
unless methods.include?(:reverse_update_metadata)
|
38
|
+
def self.reverse_update_metadata(metadata)
|
39
|
+
merged_metadata = (::PaperTrail.request.controller_info || {}).reverse_merge(metadata)
|
40
|
+
PaperTrail.request.controller_info = merged_metadata
|
41
|
+
end
|
42
|
+
end
|
30
43
|
end
|
data/lib/paper_trail/rails.rb
CHANGED
@@ -30,8 +30,10 @@ module PaperTrail
|
|
30
30
|
|
31
31
|
# Store some metadata about where the change came from
|
32
32
|
def set_default_metadata
|
33
|
-
PaperTrail.
|
33
|
+
PaperTrail.reverse_update_metadata(
|
34
34
|
command: default_command,
|
35
|
+
)
|
36
|
+
PaperTrail.update_metadata(
|
35
37
|
source_location: caller.find { |line|
|
36
38
|
line.starts_with? ::Rails.root.to_s and
|
37
39
|
config.source_location_filter.(line)
|