recorder 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/recorder/revision.rb +1 -1
- data/lib/recorder/tape/data.rb +14 -6
- data/lib/recorder/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807b7bea0674cab9a3a39b1fa03f78a62f0313650bb7adf51860a98257273186
|
4
|
+
data.tar.gz: 175315c3c23acef56bd6f9545681b7525eb41a11cadacf5e671dd197352f31d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eb1a672f08d66c265f6d1b1dffd8d65703b4359f789febb42846f4bb0d89d860c49ffb383b78bd57f3bfefeb349fac6abd7ed8ecc890a22ffc45886087c91b7
|
7
|
+
data.tar.gz: b65ed4fc4d7fea8a5d442f301789e497d538fa57447a320328f89650e9c65f8773d7247c68e303d49cdbda5977786fb64a8841c1cb5ba65a1aaa638ce9f63a3c
|
data/.gitignore
CHANGED
data/lib/recorder/revision.rb
CHANGED
@@ -76,7 +76,7 @@ module Recorder
|
|
76
76
|
# If `#recorder_changeset_class` method is not defined, then class name is generated as "#{class}Changeset"
|
77
77
|
# @api private
|
78
78
|
def changeset_class(object)
|
79
|
-
klass = defined?(Draper) && object.decorated? ? object.source.class : object.class
|
79
|
+
klass = (defined?(Draper) && object.decorated?) ? object.source.class : object.class
|
80
80
|
klass = klass.base_class
|
81
81
|
|
82
82
|
return klass.send(:recorder_changeset_class) if klass.respond_to?(:recorder_changeset_class)
|
data/lib/recorder/tape/data.rb
CHANGED
@@ -10,11 +10,13 @@ module Recorder
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def data_for(event, options = {})
|
13
|
-
{
|
13
|
+
data = {
|
14
14
|
**attributes_for(event, options),
|
15
15
|
**changes_for(event, options),
|
16
16
|
**associations_for(event, options)
|
17
17
|
}
|
18
|
+
|
19
|
+
record_changed?(data, event) ? data : {}
|
18
20
|
end
|
19
21
|
|
20
22
|
def attributes_for(_event, options)
|
@@ -22,11 +24,7 @@ module Recorder
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def changes_for(event, options)
|
25
|
-
changes =
|
26
|
-
case event.to_sym
|
27
|
-
when :update
|
28
|
-
sanitize_attributes(item.saved_changes, options)
|
29
|
-
end
|
27
|
+
changes = sanitize_attributes(item.saved_changes, options)
|
30
28
|
|
31
29
|
changes.present? ? {changes: changes} : {}
|
32
30
|
end
|
@@ -78,6 +76,16 @@ module Recorder
|
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
79
|
+
|
80
|
+
def record_changed?(data, event)
|
81
|
+
event.to_sym != :update || data[:changes] || associations_changed?(data)
|
82
|
+
end
|
83
|
+
|
84
|
+
def associations_changed?(data)
|
85
|
+
return if data[:associations].nil?
|
86
|
+
|
87
|
+
data[:associations].any? { |name, association| association[:changes] }
|
88
|
+
end
|
81
89
|
end
|
82
90
|
end
|
83
91
|
end
|
data/lib/recorder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Alexandrov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
209
|
+
rubygems_version: 3.4.6
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: Rails model auditor
|