acts_as_trackable 0.2.5 → 0.3.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: 2353ab54f4f786c5885ea49558c4a64ab83e8e73354d552331baf6aad1187d49
4
- data.tar.gz: 68faba93ea1357b9c19a26b1b6fa655feef9d6bfb7f46a804c5fbf2c36cd9c2b
3
+ metadata.gz: abcff87c3d8646138656b6e6c3cd3a2b77bbaa06220471cab325ce565fc7af96
4
+ data.tar.gz: 0fb60a5c6686eb0d3be23957a482184bd9fd801099ce790593c2f40e543a1e72
5
5
  SHA512:
6
- metadata.gz: 77c60ddfea4dbae4c1af501ecb6bd4c6bc4f0c99caae2be61c70685c27321e2ad4207d4a94bb18d48bab868a9380a84d379b4ec4a52fde5aa4efe719fdd68b3e
7
- data.tar.gz: 0f97fd2751759001cdf9c976740097d1d755de138ee1e7615743905721c706a4fa80da5675304a76d5ad4caf8baa519a8e6d7b804a2c3d0e91db96f2bdbc69d8
6
+ metadata.gz: 14717aee75f590338e196dd0982f60e44458ff5822280271c546f0040f79a56d7b5251e0ae8b4e5c89992e35e58b2f83c8c0008d64b64755ac8df28f6b42811f
7
+ data.tar.gz: befc693a18e30fd2ac1b7e82512d539cd193a99d9c8236706ae87790c1915456e9b7c66c09eaf59d5d820a28e6f9293f833affa5440a124930b1b7205e0c7074
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acts_as_trackable (0.2.5)
4
+ acts_as_trackable (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -65,10 +65,10 @@ GEM
65
65
  loofah (2.24.0)
66
66
  crass (~> 1.0.2)
67
67
  nokogiri (>= 1.12.0)
68
- minitest (5.25.4)
69
- nokogiri (1.18.3-arm64-darwin)
68
+ minitest (5.25.5)
69
+ nokogiri (1.18.5-arm64-darwin)
70
70
  racc (~> 1.4)
71
- nokogiri (1.18.3-x86_64-darwin)
71
+ nokogiri (1.18.5-x86_64-darwin)
72
72
  racc (~> 1.4)
73
73
  pp (0.6.2)
74
74
  prettyprint
data/changelog.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # acts_as_trackable Changelog
2
+ ## Version: 0.3.0
3
+ ### Patch
4
+ - Added support to treat STI models as one model
5
+ - Upgraded dependencies to patch CVE-2025-24855 and CVE-2024-55549
2
6
  ## Version: 0.2.5
3
7
  ### Patch
4
8
  - Upgraded dependencies to patch CVE-2025-27111 and CVE-2025-27610
@@ -8,6 +8,10 @@ module Trackable
8
8
 
9
9
  has_one :object_activity, as: :object, dependent: :destroy
10
10
 
11
+ define_method :object_activity do
12
+ ObjectActivity.find_by('object_id = ? AND (object_type = ? OR object_type = ?)', id, self.class.name, self.class.base_class.name)
13
+ end
14
+
11
15
  delegate :created_by, :updated_by, to: :object_activity, allow_nil: true
12
16
 
13
17
  after_commit :log_object_activity, on: %i[create update], if: -> { modifier.present? }
@@ -44,7 +48,13 @@ module Trackable
44
48
  end
45
49
 
46
50
  def trackable_object
47
- { object_id: send(self.class.trackable_column), object_type: self.class.name }
51
+ class_name = if self.class.fallback_to_base_class
52
+ self.class.base_class.name
53
+ else
54
+ self.class.name
55
+ end
56
+
57
+ { object_id: send(self.class.trackable_column), object_type: class_name }
48
58
  end
49
59
  end
50
60
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsTrackable
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -8,13 +8,14 @@ module ActsAsTrackable
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
- class_attribute :trackable_column
11
+ class_attribute :trackable_column, :fallback_to_base_class
12
12
  end
13
13
 
14
14
  class_methods do
15
- def acts_as_trackable(column_name = :id)
16
- self.trackable_column = column_name
17
- validate_trackable_column
15
+ def acts_as_trackable(column_name = :id, fallback_to_base_class: false)
16
+ self.trackable_column = column_name
17
+ self.fallback_to_base_class = fallback_to_base_class
18
+ validate_attributes
18
19
  include Trackable
19
20
  end
20
21
 
@@ -24,11 +25,22 @@ module ActsAsTrackable
24
25
 
25
26
  private
26
27
 
28
+ def validate_attributes
29
+ validate_trackable_column
30
+ validate_fallback_to_base_class
31
+ end
32
+
27
33
  def validate_trackable_column
28
34
  return if column_names.include?(trackable_column.to_s)
29
35
 
30
36
  raise ArgumentError, "Column '#{trackable_column}' does not exist in the table"
31
37
  end
38
+
39
+ def validate_fallback_to_base_class
40
+ return if fallback_to_base_class.nil? || [true, false].include?(fallback_to_base_class)
41
+
42
+ raise ArgumentError, 'fallback_to_base_class must be a boolean'
43
+ end
32
44
  end
33
45
  end
34
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_trackable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Keewan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-03-11 00:00:00.000000000 Z
12
+ date: 2025-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: generator_spec