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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4543c914ceefbe8ae43c8257e9666d4a91a46946
4
- data.tar.gz: 2c77cf8c199fc35fba0b073cab216fa217e96102
3
+ metadata.gz: e3cc83c5ea9096c99e6455aaaf01e7a58c016f16
4
+ data.tar.gz: a462f33b2f8bf243c2cd1dcaefa9983da0a71f18
5
5
  SHA512:
6
- metadata.gz: f8f61abbe8b2f2c7e44639eae48985a57dcec1429a99c50c72aa36a2195c3c6e294d6aa115092fb47321152483c7fdc1c250820594f6ae9e5610583bb85bf2cd
7
- data.tar.gz: 8b45d4f5a5a6c95d9bacabf705e2fd2ac3fcb361aaaa412c0bb653cdac061802d3694320e9ac66cdd39001e2e08f3c896ce17c5b0329c8c6430653cf5ac85702
6
+ metadata.gz: caa26da0c5eb6ceb89d71f392788428f5e024ab345ec8a33c489aee240bdd7dc3bdf6496042661dd30721e1ee4ec9466eae7af63479ea6dc53e534293e995eb8
7
+ data.tar.gz: c9131493861ee112b1654e8ad441a9ccaa485baa37f620ac62ba34c987690997b360460075a5218ff1f96a76a5095907ed79700d34867ea19be38a266ccae25d
@@ -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 (request = store[:audit_request]) || log_anyway
91
- body =
92
- case
93
- when AUDIT_SNAPSHOT_MODES.include?(mode)
94
- ma_eliminate_not_changed_keys(initial_data, current_data)
95
- when AUDIT_CHANGES_MODES.include?(mode)
96
- current_data
97
- else
98
- raise ArgumentError.new('Incorrect value of argument audit_type')
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
@@ -1,3 +1,3 @@
1
1
  module ModelsAuditor
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails