models_auditor 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/models_auditor/audit.rb +29 -26
- data/lib/models_auditor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3cc83c5ea9096c99e6455aaaf01e7a58c016f16
|
4
|
+
data.tar.gz: a462f33b2f8bf243c2cd1dcaefa9983da0a71f18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa26da0c5eb6ceb89d71f392788428f5e024ab345ec8a33c489aee240bdd7dc3bdf6496042661dd30721e1ee4ec9466eae7af63479ea6dc53e534293e995eb8
|
7
|
+
data.tar.gz: c9131493861ee112b1654e8ad441a9ccaa485baa37f620ac62ba34c987690997b360460075a5218ff1f96a76a5095907ed79700d34867ea19be38a266ccae25d
|
data/lib/models_auditor/audit.rb
CHANGED
@@ -87,33 +87,36 @@ module ModelsAuditor
|
|
87
87
|
Thread.new do
|
88
88
|
begin
|
89
89
|
log_anyway = !ModelsAuditor.config.audit_request_changes_only
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
90
|
+
if store[:audit_request] || log_anyway
|
91
|
+
(store[:audit_mutex] ||= Mutex.new).synchronize do
|
92
|
+
request = store[:audit_request]
|
93
|
+
body =
|
94
|
+
case
|
95
|
+
when AUDIT_SNAPSHOT_MODES.include?(mode)
|
96
|
+
ma_eliminate_not_changed_keys(initial_data, current_data)
|
97
|
+
when AUDIT_CHANGES_MODES.include?(mode)
|
98
|
+
current_data
|
99
|
+
else
|
100
|
+
raise ArgumentError.new('Incorrect value of argument audit_type')
|
101
|
+
end
|
102
|
+
|
103
|
+
if request.try(:new_record?) && !request.save
|
104
|
+
ModelsAuditor.log_error("Couldn't save request record")
|
105
|
+
ModelsAuditor.log_error(request.errors.full_messages)
|
106
|
+
return
|
107
|
+
end
|
108
|
+
record =
|
109
|
+
ModelsAuditor::AuditRecord.new(
|
110
|
+
request: request,
|
111
|
+
auditable: self,
|
112
|
+
content: body,
|
113
|
+
action: action,
|
114
|
+
bridge: bridge
|
115
|
+
)
|
116
|
+
unless record.save
|
117
|
+
ModelsAuditor.log_error("Couldn't logged changes of #{self.class.name} id: #{self.try(:id)}")
|
118
|
+
ModelsAuditor.log_error(record.errors.full_messages)
|
99
119
|
end
|
100
|
-
|
101
|
-
if request.try(:new_record?) && !request.save
|
102
|
-
ModelsAuditor.log_error("Couldn't save request record")
|
103
|
-
ModelsAuditor.log_error(request.errors.full_messages)
|
104
|
-
return
|
105
|
-
end
|
106
|
-
record =
|
107
|
-
ModelsAuditor::AuditRecord.new(
|
108
|
-
request: request,
|
109
|
-
auditable: self,
|
110
|
-
content: body,
|
111
|
-
action: action,
|
112
|
-
bridge: bridge
|
113
|
-
)
|
114
|
-
unless record.save
|
115
|
-
ModelsAuditor.log_error("Couldn't logged changes of #{self.class.name} id: #{self.try(:id)}")
|
116
|
-
ModelsAuditor.log_error(record.errors.full_messages)
|
117
120
|
end
|
118
121
|
end
|
119
122
|
rescue StandardError => e
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: models_auditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Gorbunov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|