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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11964998eab29e2ade0b5991c2dcd55f62918304afab5eab82acb8f7f4574813
4
- data.tar.gz: 6a54bce4305e0529736140246332879b95bfb3770396ceb7ef6e4d64e383fd0f
3
+ metadata.gz: 807b7bea0674cab9a3a39b1fa03f78a62f0313650bb7adf51860a98257273186
4
+ data.tar.gz: 175315c3c23acef56bd6f9545681b7525eb41a11cadacf5e671dd197352f31d2
5
5
  SHA512:
6
- metadata.gz: be73f56ca6cf864fcce8ff25cb66e2fe0c5b0c5cb59de32eb564c234a6edb5e8bba519d7bdc6255ad4ca559da5eda8456da009a09d376312ee3f23a6b6f84ca5
7
- data.tar.gz: 7df337554a0136656250967b56d5df939f3eaf82c5164702ea4f159be322109a77ad994e0653f03616d22485e03c8fa6c06a2c167c3c8c6d8f8d3e3544dfe076
6
+ metadata.gz: 8eb1a672f08d66c265f6d1b1dffd8d65703b4359f789febb42846f4bb0d89d860c49ffb383b78bd57f3bfefeb349fac6abd7ed8ecc890a22ffc45886087c91b7
7
+ data.tar.gz: b65ed4fc4d7fea8a5d442f301789e497d538fa57447a320328f89650e9c65f8773d7247c68e303d49cdbda5977786fb64a8841c1cb5ba65a1aaa638ce9f63a3c
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
  /tmp/
10
10
 
11
11
  /spec/dummy/config/database.yml
12
+ /spec/dummy/log/*
12
13
 
13
14
  # Ignore vim swap files
14
15
  *.swp
@@ -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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recorder
4
- VERSION = '1.2.2'
4
+ VERSION = '1.2.3'
5
5
  end
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.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: 2022-11-17 00:00:00.000000000 Z
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.3.7
209
+ rubygems_version: 3.4.6
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Rails model auditor