models_auditor 1.0.6 → 1.0.7
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 +39 -8
- 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: 8259cff8a18e95707305268e2d5344f500c9c1ba
|
4
|
+
data.tar.gz: 3aaa9d4ab21d8c91016ff11f29ec18755708efc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3949ea27aa765cfc676eb3934e275a060375e2a28c40e33e729d533287496170d40dcf78faf229f2e70bb578ccb4e60041fd0472b346d0f73acb86e85c525e01
|
7
|
+
data.tar.gz: 3974017de3335b66d217bf7f03ab899cb39fc915b1928b20f03aa51b3d069c16db54732a7ac37fe4c4ae31ea19c9fb3a945602ec998cc825c3b8a5bbfc21615c
|
data/lib/models_auditor/audit.rb
CHANGED
@@ -21,18 +21,49 @@ module ModelsAuditor
|
|
21
21
|
end
|
22
22
|
|
23
23
|
module InstanceMethods
|
24
|
+
def is_audit_enabled?
|
25
|
+
self.class.instance_variable_get(:@audit_enabled) ||
|
26
|
+
(self.class.column_names.include?(self.class.inheritance_column) &&
|
27
|
+
self.class.superclass.instance_variable_get(:@audit_enabled))
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_audit_mode
|
31
|
+
mode = self.class.instance_variable_get(:@audit_mode)
|
32
|
+
if mode.nil?
|
33
|
+
self.class.column_names.include?(self.class.inheritance_column) &&
|
34
|
+
self.class.superclass.instance_variable_get(:@audit_enabled) ?
|
35
|
+
self.class.superclass.instance_variable_get(:@audit_mode) :
|
36
|
+
nil
|
37
|
+
else
|
38
|
+
mode
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_audit_options
|
43
|
+
settings = self.class.instance_variable_get(:@audit_settings)
|
44
|
+
if settings.nil?
|
45
|
+
self.class.column_names.include?(self.class.inheritance_column) &&
|
46
|
+
self.class.superclass.instance_variable_get(:@audit_enabled) ?
|
47
|
+
self.class.superclass.instance_variable_get(:@audit_settings) :
|
48
|
+
{}
|
49
|
+
else
|
50
|
+
settings
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
24
54
|
def do_audit_init_snapshot
|
25
55
|
return unless ModelsAuditor.config.audit_enabled
|
26
|
-
|
27
|
-
|
56
|
+
return unless is_audit_enabled?
|
57
|
+
mode = get_audit_mode
|
58
|
+
return unless AUDIT_SNAPSHOT_MODES.include?(mode)
|
28
59
|
ma_store_initial_state(ModelsAuditor.store)
|
29
60
|
end
|
30
61
|
|
31
62
|
def do_audit_process
|
32
63
|
return unless ModelsAuditor.config.audit_enabled
|
33
|
-
return unless
|
34
|
-
mode =
|
35
|
-
options =
|
64
|
+
return unless is_audit_enabled?
|
65
|
+
mode = get_audit_mode
|
66
|
+
options = get_audit_options
|
36
67
|
store = ModelsAuditor.store
|
37
68
|
|
38
69
|
initial_data = ma_get_initial_state(store)
|
@@ -135,9 +166,9 @@ module ModelsAuditor
|
|
135
166
|
|
136
167
|
# Получает сериализованные данные для аудита
|
137
168
|
def ma_auditor_get_data
|
138
|
-
options =
|
169
|
+
options = get_audit_options
|
139
170
|
audit_params = options[:params]
|
140
|
-
mode =
|
171
|
+
mode = get_audit_mode
|
141
172
|
case mode
|
142
173
|
when AUDIT_MODE_JSON
|
143
174
|
self.as_json(audit_params)
|
@@ -157,7 +188,7 @@ module ModelsAuditor
|
|
157
188
|
when AUDIT_MODE_CHANGES_ONLY
|
158
189
|
self.previous_changes
|
159
190
|
else
|
160
|
-
raise ArgumentError.new(
|
191
|
+
raise ArgumentError.new("Incorrect value of argument audit_type #{mode}")
|
161
192
|
end
|
162
193
|
end
|
163
194
|
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.0.
|
4
|
+
version: 1.0.7
|
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
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|