effective_logging 4.3.1 → 4.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4822036f0b48e1a0821851a0822c684660456a901c06bdaa4a311d58fb0021fb
4
- data.tar.gz: 27456ca9fc65eea77f89ed81699d531aba19d4aab807b38cc278943622f84433
3
+ metadata.gz: f22bddc98d1fa95eaeb3f28f0d2a44c8d1d7a8cb27c0f7d1febfc0b8f0497e6f
4
+ data.tar.gz: 53134b2a065bcc66943ce5df4ae3cbd6d4c9a83a1b961ecef6268a3a2a40087b
5
5
  SHA512:
6
- metadata.gz: efc109a5104461e0434689479fc068f530ca3dbeebadc6c63934b61a44866bd3c74334bb3f4c4da506f8954218ac195f894e512ef5e712ccbe94f9c408a940f3
7
- data.tar.gz: b5fdf769f927ad4708bf6620e739a093a7a66861484b6fd8c451f176dd2988b5247ba1107d3c81f1fc3ac44f7adee805c6c28f6230603b7f3577532f21fd638d
6
+ metadata.gz: ba49175caf9d855c6ca803fe24e12b7593c66679239ab15c1513802a43630c187dae391346dda8c87c217d015ae491d78115fb8208289bb0537ca870da9889bc
7
+ data.tar.gz: 65f1623c2321aeda6b5c1448077099ee6bf91865bc892950930d4361c87637a3acb788e7ef19fbbba146c4afdb68d3ea5b6698c62285b646b0c277755c21a83e
@@ -59,6 +59,14 @@ module ActsAsLoggable
59
59
  true # Can be overridden to suppress logging
60
60
  end
61
61
 
62
+ def log_changes_to_s
63
+ if self.class.name == 'ActiveStorage::Attachment'
64
+ "#{name} - #{filename}"
65
+ else
66
+ to_s
67
+ end
68
+ end
69
+
62
70
  # Format the title of this attribute. Return nil to use the default attribute.titleize
63
71
  def log_changes_formatted_attribute(attribute)
64
72
  'Roles' if attribute == :roles_mask && defined?(EffectiveRoles) && respond_to?(:roles)
@@ -46,7 +46,7 @@ module EffectiveLogging
46
46
  EffectiveLogging.Log.create!(
47
47
  changes_to: log_changes_to,
48
48
  associated: object,
49
- associated_to_s: (object.to_s rescue nil),
49
+ associated_to_s: (object.log_changes_to_s rescue nil),
50
50
  user: EffectiveLogging.current_user,
51
51
  status: EffectiveLogging.log_changes_status,
52
52
  message: [options[:prefix].presence, message].compact.join,
@@ -44,6 +44,15 @@ module EffectiveLogging
44
44
  end
45
45
  end
46
46
 
47
+ # Add log_changes to ActiveStorage::Attachment
48
+ initializer 'effective_logging.active_storage_attachment' do |app|
49
+ if defined?(ActiveStorage)
50
+ app.config.to_prepare do
51
+ ActiveStorage::Attachment.class_eval { log_changes(to: :record) }
52
+ end
53
+ end
54
+ end
55
+
47
56
  # Register the log_page_views concern so that it can be called in ActionController or elsewhere
48
57
  initializer 'effective_logging.log_changes_action_controller' do |app|
49
58
  app.config.to_prepare do
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '4.3.1'.freeze
2
+ VERSION = '4.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
11
+ date: 2025-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails