recorder 0.1.11 → 0.1.12
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/lib/recorder/config.rb +7 -1
- data/lib/recorder/tape.rb +9 -16
- data/lib/recorder/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3af9ad0f9d54d04d84de1389c3a7170c8d92f16c
|
4
|
+
data.tar.gz: ccb3fd47554c553ec486bda99d5f6d4dd8814841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335f64716495f041b884caed43b2e5046186f314136d6676ba6abe67bce1c5879240651d110a6cd704d37c0d804cc8ec2077b99beb67e6c691c07d140036bec4
|
7
|
+
data.tar.gz: f9ec4e0f024f55031f7d799461fabbc08430fb5de588c90d2ffae80767d5d6bad43cd67cfaaee54316990af6ad8a5d65498a3780479f927d36ffd41070429be3
|
data/lib/recorder/config.rb
CHANGED
@@ -4,7 +4,7 @@ module Recorder
|
|
4
4
|
# Global configuration options
|
5
5
|
class Config
|
6
6
|
include Singleton
|
7
|
-
attr_accessor :sidekiq_options
|
7
|
+
attr_accessor :sidekiq_options, :ignore
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
# Variables which affect all threads, whose access is synchronized.
|
@@ -16,6 +16,12 @@ module Recorder
|
|
16
16
|
:retry => 10,
|
17
17
|
:backtrace => true
|
18
18
|
}
|
19
|
+
|
20
|
+
@ignore = Array.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def ignore=(value)
|
24
|
+
@ignore = Array.wrap(value)
|
19
25
|
end
|
20
26
|
|
21
27
|
# Indicates whether Recorder is on or off. Default: true.
|
data/lib/recorder/tape.rb
CHANGED
@@ -24,6 +24,9 @@ module Recorder
|
|
24
24
|
def record_create
|
25
25
|
data = self.changes_for(:create)
|
26
26
|
|
27
|
+
associations_attributes = self.parse_associations_attributes(:create)
|
28
|
+
data.merge!(:associations => associations_attributes) if associations_attributes.present?
|
29
|
+
|
27
30
|
if data.any?
|
28
31
|
self.record(
|
29
32
|
Recorder.store.merge({
|
@@ -35,14 +38,10 @@ module Recorder
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def record_update
|
38
|
-
# data = {
|
39
|
-
# :changes => self.sanitize_attributes(self.item.previous_changes)
|
40
|
-
# }
|
41
|
-
|
42
41
|
data = self.changes_for(:update)
|
43
42
|
|
44
|
-
|
45
|
-
data.merge!(:associations =>
|
43
|
+
associations_attributes = self.parse_associations_attributes(:update)
|
44
|
+
data.merge!(:associations => associations_attributes) if associations_attributes.present?
|
46
45
|
|
47
46
|
if data.any?
|
48
47
|
self.record(
|
@@ -72,11 +71,11 @@ module Recorder
|
|
72
71
|
end
|
73
72
|
|
74
73
|
def sanitize_attributes(attributes = {})
|
75
|
-
if self.item.respond_to?(:recorder_options) && self.item.recorder_options[:
|
76
|
-
|
77
|
-
attributes.symbolize_keys.except(*
|
74
|
+
if self.item.respond_to?(:recorder_options) && self.item.recorder_options[:ignore].present?
|
75
|
+
ignore = Array.wrap(self.item.recorder_options[:ignore])
|
76
|
+
attributes.symbolize_keys.except(*ignore)
|
78
77
|
else
|
79
|
-
attributes
|
78
|
+
attributes.symbolize_keys.except(*Recorder.config.ignore)
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
@@ -92,12 +91,6 @@ module Recorder
|
|
92
91
|
changes = Recorder::Tape.new(object).changes_for(event)
|
93
92
|
hash[reflection.name] = changes if changes.any?
|
94
93
|
end
|
95
|
-
|
96
|
-
# if object.present? && self.sanitize_attributes(object.previous_changes).any?
|
97
|
-
# hash[reflection.name] = {
|
98
|
-
# :changes => self.sanitize_attributes(object.previous_changes)
|
99
|
-
# }
|
100
|
-
# end
|
101
94
|
end
|
102
95
|
end
|
103
96
|
|
data/lib/recorder/version.rb
CHANGED