acts_as_trackable 0.2.4 → 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 +4 -4
- data/Gemfile.lock +5 -5
- data/changelog.md +7 -0
- data/lib/acts_as_trackable/trackable.rb +11 -1
- data/lib/acts_as_trackable/version.rb +1 -1
- data/lib/acts_as_trackable.rb +16 -4
- 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: abcff87c3d8646138656b6e6c3cd3a2b77bbaa06220471cab325ce565fc7af96
|
4
|
+
data.tar.gz: 0fb60a5c6686eb0d3be23957a482184bd9fd801099ce790593c2f40e543a1e72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
69
|
-
nokogiri (1.18.
|
68
|
+
minitest (5.25.5)
|
69
|
+
nokogiri (1.18.5-arm64-darwin)
|
70
70
|
racc (~> 1.4)
|
71
|
-
nokogiri (1.18.
|
71
|
+
nokogiri (1.18.5-x86_64-darwin)
|
72
72
|
racc (~> 1.4)
|
73
73
|
pp (0.6.2)
|
74
74
|
prettyprint
|
@@ -77,7 +77,7 @@ GEM
|
|
77
77
|
date
|
78
78
|
stringio
|
79
79
|
racc (1.8.1)
|
80
|
-
rack (3.1.
|
80
|
+
rack (3.1.12)
|
81
81
|
rack-session (2.1.0)
|
82
82
|
base64 (>= 0.1.0)
|
83
83
|
rack (>= 3.0.0)
|
data/changelog.md
CHANGED
@@ -1,4 +1,11 @@
|
|
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
|
6
|
+
## Version: 0.2.5
|
7
|
+
### Patch
|
8
|
+
- Upgraded dependencies to patch CVE-2025-27111 and CVE-2025-27610
|
2
9
|
## Version: 0.2.4
|
3
10
|
### Patch
|
4
11
|
- Upgraded dependencies to patch CVE-2025-24928 and CVE-2024-56171
|
@@ -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
|
-
|
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
|
data/lib/acts_as_trackable.rb
CHANGED
@@ -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
|
17
|
-
|
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.
|
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-
|
12
|
+
date: 2025-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: generator_spec
|