velocity_audited 5.1.4 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -15
- data/lib/audited/audit.rb +9 -9
- data/lib/audited/auditor.rb +26 -23
- data/lib/audited/railtie.rb +3 -3
- data/lib/audited/rspec_matchers.rb +2 -2
- data/lib/audited/sweeper.rb +10 -10
- data/lib/audited/version.rb +2 -2
- data/lib/audited-rspec.rb +1 -1
- data/lib/generators/audited/install_generator.rb +3 -3
- data/lib/generators/audited/migration.rb +1 -1
- data/lib/generators/audited/migration_helper.rb +1 -1
- data/lib/generators/audited/upgrade_generator.rb +6 -6
- data/lib/velocity_audited.rb +29 -33
- data/spec/audited/audit_spec.rb +32 -32
- data/spec/audited/auditor_spec.rb +41 -41
- data/spec/audited/sweeper_spec.rb +11 -11
- data/spec/spec_helper.rb +1 -1
- data/spec/velocity_audited_spec.rb +18 -0
- data/test/install_generator_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/upgrade_generator_test.rb +1 -1
- metadata +3 -4
- data/lib/audited.rb +0 -49
- data/spec/audited_spec.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b39436e9380cd8f81939d01bd864c669d65bb033ef97d7c265165160e52809c
|
4
|
+
data.tar.gz: 761804b094627fcb2b13e991ec8eb66288f1761d3d9ba4b134811d3ed399b3b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebd15ee11f7c91d2beb3c61db75d6a6c8a3795c8615423d9c9ad9ed9294d321ad5439427adba2a45238318d4e79fa1183a5401250d62ed945b36ee25f03091b6
|
7
|
+
data.tar.gz: 0621c54999850e9a6cd4cbe12642cc1e99ea0e367119aba2a503009f290ea5cc99374dab67d34e2e8c9007a4f51ee660c5429c6607ecc3917fa5bb3260f16bdf
|
data/README.md
CHANGED
@@ -42,10 +42,10 @@ gem "audited", "~> 5.0"
|
|
42
42
|
And if you're using ```require: false``` you must add initializers like this:
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
#./config/initializers/
|
46
|
-
require "
|
45
|
+
#./config/initializers/velocity_audited.rb
|
46
|
+
require "velocity_audited"
|
47
47
|
|
48
|
-
|
48
|
+
VelocityAudited::Railtie.initializers.each(&:run)
|
49
49
|
```
|
50
50
|
|
51
51
|
Then, from your Rails app directory, create the `audits` table:
|
@@ -174,7 +174,7 @@ end
|
|
174
174
|
You can limit the number of audits stored for your model. To configure limiting for all audited models, put the following in an initializer file (`config/initializers/audited.rb`):
|
175
175
|
|
176
176
|
```ruby
|
177
|
-
|
177
|
+
VelocityAudited.max_audits = 10 # keep only 10 latest audits
|
178
178
|
```
|
179
179
|
|
180
180
|
or customize per model:
|
@@ -213,13 +213,13 @@ end
|
|
213
213
|
To use a method other than `current_user`, put the following in an initializer file (`config/initializers/audited.rb`):
|
214
214
|
|
215
215
|
```ruby
|
216
|
-
|
216
|
+
VelocityAudited.current_user_method = :authenticated_user
|
217
217
|
```
|
218
218
|
|
219
219
|
Outside of a request, Audited can still record the user with the `as_user` method:
|
220
220
|
|
221
221
|
```ruby
|
222
|
-
|
222
|
+
VelocityAudited.audit_class.as_user(User.find(1)) do
|
223
223
|
post.update!(title: "Hello, world!")
|
224
224
|
end
|
225
225
|
post.audits.last.user # => #<User id: 1>
|
@@ -246,7 +246,7 @@ end
|
|
246
246
|
`as_user` also accepts a string, which can be useful for auditing updates made in a CLI environment:
|
247
247
|
|
248
248
|
```rb
|
249
|
-
|
249
|
+
VelocityAudited.audit_class.as_user("console-user-#{ENV['SSH_USER']}") do
|
250
250
|
post.update_attributes!(title: "Hello, world!")
|
251
251
|
end
|
252
252
|
post.audits.last.user # => 'console-user-username'
|
@@ -255,11 +255,11 @@ post.audits.last.user # => 'console-user-username'
|
|
255
255
|
If you want to set a specific user as the auditor of the commands in a CLI environment, whether that is a string or an ActiveRecord object, you can use the following command:
|
256
256
|
|
257
257
|
```rb
|
258
|
-
|
258
|
+
VelocityAudited.store[:audited_user] = "username"
|
259
259
|
|
260
260
|
# or
|
261
261
|
|
262
|
-
|
262
|
+
VelocityAudited.store[:audited_user] = User.find(1)
|
263
263
|
```
|
264
264
|
|
265
265
|
### Associated Audits
|
@@ -366,7 +366,7 @@ User.auditing_enabled = false
|
|
366
366
|
To disable auditing on all models:
|
367
367
|
|
368
368
|
```ruby
|
369
|
-
|
369
|
+
VelocityAudited.auditing_enabled = false
|
370
370
|
```
|
371
371
|
|
372
372
|
If you have auditing disabled by default on your model you can enable auditing
|
@@ -390,18 +390,20 @@ end
|
|
390
390
|
|
391
391
|
If you want to extend or modify the audit model, create a new class that
|
392
392
|
inherits from `Audited::Audit`:
|
393
|
+
|
393
394
|
```ruby
|
394
|
-
class CustomAudit <
|
395
|
+
class CustomAudit < VelocityAudited::Audit
|
395
396
|
def some_custom_behavior
|
396
397
|
"Hiya!"
|
397
398
|
end
|
398
399
|
end
|
399
400
|
```
|
400
401
|
Then set it in an initializer:
|
402
|
+
|
401
403
|
```ruby
|
402
|
-
# config/initializers/
|
404
|
+
# config/initializers/velocity_audited.rb
|
403
405
|
|
404
|
-
|
406
|
+
VelocityAudited.config do |config|
|
405
407
|
config.audit_class = CustomAudit
|
406
408
|
end
|
407
409
|
```
|
@@ -411,9 +413,9 @@ end
|
|
411
413
|
In 4.10, the default behavior for enums changed from storing the value synthesized by Rails to the value stored in the DB. You can restore the previous behavior by setting the store_synthesized_enums configuration value:
|
412
414
|
|
413
415
|
```ruby
|
414
|
-
# config/initializers/
|
416
|
+
# config/initializers/velocity_audited.rb
|
415
417
|
|
416
|
-
|
418
|
+
VelocityAudited.store_synthesized_enums = true
|
417
419
|
```
|
418
420
|
|
419
421
|
## Support
|
data/lib/audited/audit.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "set"
|
4
4
|
|
5
|
-
module
|
5
|
+
module VelocityAudited
|
6
6
|
# Audit saves the changes to ActiveRecord models. It has the following attributes:
|
7
7
|
#
|
8
8
|
# * <tt>auditable</tt>: the ActiveRecord model that was changed
|
@@ -34,7 +34,7 @@ module Audited
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def text_column?
|
37
|
-
|
37
|
+
VelocityAudited.audit_class.columns_hash["audited_changes"].type.to_s == "text"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -134,11 +134,11 @@ module Audited
|
|
134
134
|
# by +user+. This method is hopefully threadsafe, making it ideal
|
135
135
|
# for background operations that require audit information.
|
136
136
|
def self.as_user(user)
|
137
|
-
last_audited_user = ::
|
138
|
-
::
|
137
|
+
last_audited_user = ::VelocityAudited.store[:audited_user]
|
138
|
+
::VelocityAudited.store[:audited_user] = user
|
139
139
|
yield
|
140
140
|
ensure
|
141
|
-
::
|
141
|
+
::VelocityAudited.store[:audited_user] = last_audited_user
|
142
142
|
end
|
143
143
|
|
144
144
|
# @private
|
@@ -181,18 +181,18 @@ module Audited
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def set_audit_user
|
184
|
-
self.user ||= ::
|
185
|
-
self.user ||= ::
|
184
|
+
self.user ||= ::VelocityAudited.store[:audited_user] # from .as_user
|
185
|
+
self.user ||= ::VelocityAudited.store[:current_user].try!(:call) # from Sweeper
|
186
186
|
nil # prevent stopping callback chains
|
187
187
|
end
|
188
188
|
|
189
189
|
def set_request_uuid
|
190
|
-
self.request_uuid ||= ::
|
190
|
+
self.request_uuid ||= ::VelocityAudited.store[:current_request_uuid]
|
191
191
|
self.request_uuid ||= SecureRandom.uuid
|
192
192
|
end
|
193
193
|
|
194
194
|
def set_remote_address
|
195
|
-
self.remote_address ||= ::
|
195
|
+
self.remote_address ||= ::VelocityAudited.store[:current_remote_address]
|
196
196
|
end
|
197
197
|
end
|
198
198
|
end
|
data/lib/audited/auditor.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module VelocityAudited
|
4
4
|
# Specify this act if you want changes to your model to be saved in an
|
5
5
|
# audit table. This assumes there is an audits table ready.
|
6
6
|
#
|
@@ -60,10 +60,10 @@ module Audited
|
|
60
60
|
#
|
61
61
|
def audited(options = {})
|
62
62
|
# don't allow multiple calls
|
63
|
-
return if included_modules.include?(
|
63
|
+
return if included_modules.include?(VelocityAudited::Auditor::AuditedInstanceMethods)
|
64
64
|
|
65
|
-
extend
|
66
|
-
include
|
65
|
+
extend VelocityAudited::Auditor::AuditedClassMethods
|
66
|
+
include VelocityAudited::Auditor::AuditedInstanceMethods
|
67
67
|
|
68
68
|
class_attribute :audit_associated_with, instance_writer: false
|
69
69
|
class_attribute :audited_options, instance_writer: false
|
@@ -79,8 +79,8 @@ module Audited
|
|
79
79
|
before_destroy :require_comment if audited_options[:on].include?(:destroy)
|
80
80
|
end
|
81
81
|
|
82
|
-
has_many :audits, -> { order(version: :asc) }, as: :auditable, class_name:
|
83
|
-
|
82
|
+
has_many :audits, -> { order(version: :asc) }, as: :auditable, class_name: VelocityAudited.audit_class.name, inverse_of: :auditable
|
83
|
+
VelocityAudited.audit_class.audited_class_names << to_s
|
84
84
|
|
85
85
|
after_create :audit_create if audited_options[:on].include?(:create)
|
86
86
|
before_update :audit_update if audited_options[:on].include?(:update)
|
@@ -97,7 +97,7 @@ module Audited
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def has_associated_audits
|
100
|
-
has_many :associated_audits, as: :associated, class_name:
|
100
|
+
has_many :associated_audits, as: :associated, class_name: VelocityAudited.audit_class.name
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -159,14 +159,14 @@ module Audited
|
|
159
159
|
# Returns nil for versions greater than revisions count
|
160
160
|
def revision(version)
|
161
161
|
if version == :previous || audits.last.version >= version
|
162
|
-
revision_with
|
162
|
+
revision_with VelocityAudited.audit_class.reconstruct_attributes(audits_to(version))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
# Find the oldest revision recorded prior to the date/time provided.
|
167
167
|
def revision_at(date_or_time)
|
168
168
|
audits = self.audits.up_until(date_or_time)
|
169
|
-
revision_with
|
169
|
+
revision_with VelocityAudited.audit_class.reconstruct_attributes(audits) unless audits.empty?
|
170
170
|
end
|
171
171
|
|
172
172
|
# List of attributes that are audited.
|
@@ -177,7 +177,7 @@ module Audited
|
|
177
177
|
|
178
178
|
# Returns a list combined of record audits and associated audits.
|
179
179
|
def own_and_associated_audits
|
180
|
-
|
180
|
+
VelocityAudited.audit_class.unscoped
|
181
181
|
.where("(auditable_type = :type AND auditable_id = :id) OR (associated_type = :type AND associated_id = :id)",
|
182
182
|
type: self.class.base_class.name, id: id)
|
183
183
|
.order(created_at: :desc)
|
@@ -206,7 +206,7 @@ module Audited
|
|
206
206
|
revision.send :instance_variable_set, "@destroyed", false
|
207
207
|
revision.send :instance_variable_set, "@_destroyed", false
|
208
208
|
revision.send :instance_variable_set, "@marked_for_destruction", false
|
209
|
-
|
209
|
+
VelocityAudited.audit_class.assign_revision_attributes(revision, attributes)
|
210
210
|
|
211
211
|
# Remove any association proxies so that they will be recreated
|
212
212
|
# and reference the correct object for this revision. The only way
|
@@ -239,7 +239,7 @@ module Audited
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def normalize_enum_changes(changes)
|
242
|
-
return changes if
|
242
|
+
return changes if VelocityAudited.store_synthesized_enums
|
243
243
|
|
244
244
|
self.class.defined_enums.each do |name, values|
|
245
245
|
if changes.has_key?(name)
|
@@ -310,19 +310,22 @@ module Audited
|
|
310
310
|
def write_audit(attrs)
|
311
311
|
self.audit_comment = nil
|
312
312
|
attrs[:db_audit] = true
|
313
|
+
attrs[:record_id] = id
|
314
|
+
attrs[:model] = self.class.base_class.name
|
313
315
|
attrs = add_metadata(attrs)
|
314
316
|
if auditing_enabled
|
315
317
|
attrs[:associated] = send(audit_associated_with) unless audit_associated_with.nil?
|
316
|
-
logger.
|
318
|
+
logger.info(attrs.to_json)
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
320
322
|
def add_metadata(attrs)
|
321
|
-
attrs[:client] = ::
|
322
|
-
attrs[:origin] = ::
|
323
|
-
attrs[:user_agent] = ::
|
324
|
-
attrs[:ip] = ::
|
325
|
-
attrs[:uid] = ::
|
323
|
+
attrs[:client] = ::VelocityAudited.store[:client]
|
324
|
+
attrs[:origin] = ::VelocityAudited.store[:origin]
|
325
|
+
attrs[:user_agent] = ::VelocityAudited.store[:user_agent]
|
326
|
+
attrs[:ip] = ::VelocityAudited.store[:current_remote_address]
|
327
|
+
attrs[:uid] = ::VelocityAudited.store[:uid]
|
328
|
+
attrs[:request_id] = ::VelocityAudited.store[:request_id]
|
326
329
|
attrs
|
327
330
|
end
|
328
331
|
|
@@ -436,19 +439,19 @@ module Audited
|
|
436
439
|
# convenience wrapper around
|
437
440
|
# @see Audit#as_user.
|
438
441
|
def audit_as(user, &block)
|
439
|
-
|
442
|
+
VelocityAudited.audit_class.as_user(user, &block)
|
440
443
|
end
|
441
444
|
|
442
445
|
def auditing_enabled
|
443
|
-
|
446
|
+
VelocityAudited.store.fetch("#{table_name}_auditing_enabled", true) && VelocityAudited.auditing_enabled
|
444
447
|
end
|
445
448
|
|
446
449
|
def auditing_enabled=(val)
|
447
|
-
|
450
|
+
VelocityAudited.store["#{table_name}_auditing_enabled"] = val
|
448
451
|
end
|
449
452
|
|
450
453
|
def default_ignored_attributes
|
451
|
-
[primary_key, inheritance_column] |
|
454
|
+
[primary_key, inheritance_column] | VelocityAudited.ignored_attributes
|
452
455
|
end
|
453
456
|
|
454
457
|
protected
|
@@ -458,7 +461,7 @@ module Audited
|
|
458
461
|
audited_options[:on] = [:create, :update, :destroy] if audited_options[:on].empty?
|
459
462
|
audited_options[:only] = Array.wrap(audited_options[:only]).map(&:to_s)
|
460
463
|
audited_options[:except] = Array.wrap(audited_options[:except]).map(&:to_s)
|
461
|
-
max_audits = audited_options[:max_audits] ||
|
464
|
+
max_audits = audited_options[:max_audits] || VelocityAudited.max_audits
|
462
465
|
audited_options[:max_audits] = Integer(max_audits).abs if max_audits
|
463
466
|
end
|
464
467
|
|
data/lib/audited/railtie.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module VelocityAudited
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
initializer "audited.sweeper" do
|
6
6
|
ActiveSupport.on_load(:action_controller) do
|
7
7
|
if defined?(ActionController::Base)
|
8
|
-
ActionController::Base.around_action
|
8
|
+
ActionController::Base.around_action VelocityAudited::Sweeper.new
|
9
9
|
end
|
10
10
|
if defined?(ActionController::API)
|
11
|
-
ActionController::API.around_action
|
11
|
+
ActionController::API.around_action VelocityAudited::Sweeper.new
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module VelocityAudited
|
4
4
|
module RspecMatchers
|
5
5
|
# Ensure that the model is audited.
|
6
6
|
#
|
@@ -221,7 +221,7 @@ module Audited
|
|
221
221
|
def association_exists?
|
222
222
|
!reflection.nil? &&
|
223
223
|
reflection.macro == :has_many &&
|
224
|
-
reflection.options[:class_name] ==
|
224
|
+
reflection.options[:class_name] == VelocityAudited.audit_class.name
|
225
225
|
end
|
226
226
|
end
|
227
227
|
end
|
data/lib/audited/sweeper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module VelocityAudited
|
4
4
|
class Sweeper
|
5
5
|
STORED_DATA = {
|
6
6
|
current_remote_address: :remote_ip,
|
@@ -8,12 +8,12 @@ module Audited
|
|
8
8
|
current_user: :current_user,
|
9
9
|
origin: :origin,
|
10
10
|
user_agent: :user_agent,
|
11
|
-
ip: :ip,
|
12
11
|
uid: :uid,
|
13
|
-
client: :client
|
12
|
+
client: :client,
|
13
|
+
request_id: :request_id
|
14
14
|
}
|
15
15
|
|
16
|
-
delegate :store, to: ::
|
16
|
+
delegate :store, to: ::VelocityAudited
|
17
17
|
|
18
18
|
def around(controller)
|
19
19
|
self.controller = controller
|
@@ -25,7 +25,7 @@ module Audited
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def current_user
|
28
|
-
lambda { controller.send(
|
28
|
+
lambda { controller.send(VelocityAudited.current_user_method) if controller.respond_to?(VelocityAudited.current_user_method, true) }
|
29
29
|
end
|
30
30
|
|
31
31
|
def remote_ip
|
@@ -43,11 +43,7 @@ module Audited
|
|
43
43
|
def user_agent
|
44
44
|
controller.try(:request).try(:headers)['User-Agent']
|
45
45
|
end
|
46
|
-
|
47
|
-
def ip
|
48
|
-
controller.try(:request).try(:headers)['HTTP_X_FORWARDED_FOR']
|
49
|
-
end
|
50
|
-
|
46
|
+
|
51
47
|
def uid
|
52
48
|
controller.try(:request).try(:headers)['uid']
|
53
49
|
end
|
@@ -56,6 +52,10 @@ module Audited
|
|
56
52
|
controller.try(:request).try(:headers)['client']
|
57
53
|
end
|
58
54
|
|
55
|
+
def request_id
|
56
|
+
controller.try(:request).try(:uuid)
|
57
|
+
end
|
58
|
+
|
59
59
|
def controller
|
60
60
|
store[:current_controller]
|
61
61
|
end
|
data/lib/audited/version.rb
CHANGED
data/lib/audited-rspec.rb
CHANGED
@@ -7,12 +7,12 @@ require "rails/generators/active_record"
|
|
7
7
|
require "generators/audited/migration"
|
8
8
|
require "generators/audited/migration_helper"
|
9
9
|
|
10
|
-
module
|
10
|
+
module VelocityAudited
|
11
11
|
module Generators
|
12
12
|
class InstallGenerator < Rails::Generators::Base
|
13
13
|
include Rails::Generators::Migration
|
14
|
-
include
|
15
|
-
extend
|
14
|
+
include VelocityAudited::Generators::MigrationHelper
|
15
|
+
extend VelocityAudited::Generators::Migration
|
16
16
|
|
17
17
|
class_option :audited_changes_column_type, type: :string, default: "text", required: false
|
18
18
|
class_option :audited_user_id_column_type, type: :string, default: "integer", required: false
|
@@ -7,12 +7,12 @@ require "rails/generators/active_record"
|
|
7
7
|
require "generators/audited/migration"
|
8
8
|
require "generators/audited/migration_helper"
|
9
9
|
|
10
|
-
module
|
10
|
+
module VelocityAudited
|
11
11
|
module Generators
|
12
12
|
class UpgradeGenerator < Rails::Generators::Base
|
13
13
|
include Rails::Generators::Migration
|
14
|
-
include
|
15
|
-
extend
|
14
|
+
include VelocityAudited::Generators::MigrationHelper
|
15
|
+
extend VelocityAudited::Generators::Migration
|
16
16
|
|
17
17
|
source_root File.expand_path("../templates", __FILE__)
|
18
18
|
|
@@ -25,9 +25,9 @@ module Audited
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def migrations_to_be_applied
|
28
|
-
|
29
|
-
columns =
|
30
|
-
indexes =
|
28
|
+
VelocityAudited::Audit.reset_column_information
|
29
|
+
columns = VelocityAudited::Audit.columns.map(&:name)
|
30
|
+
indexes = VelocityAudited::Audit.connection.indexes(VelocityAudited::Audit.table_name)
|
31
31
|
|
32
32
|
yield :add_comment_to_audits unless columns.include?("comment")
|
33
33
|
|
data/lib/velocity_audited.rb
CHANGED
@@ -1,53 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_record"
|
2
4
|
|
3
5
|
module VelocityAudited
|
4
|
-
|
5
|
-
|
6
|
-
module Audited
|
7
|
-
class << self
|
8
|
-
attr_accessor \
|
6
|
+
class << self
|
7
|
+
attr_accessor \
|
9
8
|
:auditing_enabled,
|
10
9
|
:current_user_method,
|
11
10
|
:ignored_attributes,
|
12
11
|
:max_audits,
|
13
12
|
:store_synthesized_enums
|
14
|
-
|
15
|
-
|
16
|
-
def audit_class
|
17
|
-
@audit_class ||= Audit
|
18
|
-
end
|
13
|
+
attr_writer :audit_class
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
def audit_class
|
16
|
+
@audit_class ||= Audit
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
current_store_value
|
27
|
-
end
|
28
|
-
end
|
19
|
+
def store
|
20
|
+
current_store_value = Thread.current.thread_variable_get(:audited_store)
|
29
21
|
|
30
|
-
|
31
|
-
|
22
|
+
if current_store_value.nil?
|
23
|
+
Thread.current.thread_variable_set(:audited_store, {})
|
24
|
+
else
|
25
|
+
current_store_value
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@auditing_enabled = true
|
39
|
-
@store_synthesized_enums = false
|
29
|
+
def config
|
30
|
+
yield(self)
|
31
|
+
end
|
40
32
|
end
|
41
33
|
|
42
|
-
|
34
|
+
@ignored_attributes = %w[lock_version created_at updated_at created_on updated_on]
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
@current_user_method = :current_user
|
37
|
+
@auditing_enabled = true
|
38
|
+
@store_synthesized_enums = false
|
39
|
+
end
|
48
40
|
|
49
|
-
|
50
|
-
require "audited/railtie"
|
41
|
+
require "audited/auditor"
|
51
42
|
|
43
|
+
ActiveSupport.on_load :active_record do
|
44
|
+
require "audited/audit"
|
45
|
+
include VelocityAudited::Auditor
|
46
|
+
end
|
52
47
|
|
53
|
-
|
48
|
+
require "audited/sweeper"
|
49
|
+
require "audited/railtie"
|