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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 284c1bc23118fdc7bc7d8bd37ac1b1bd705796ab
4
- data.tar.gz: 1aa407eba7453c44efb9726eb8b4b4e3042b2930
3
+ metadata.gz: 3af9ad0f9d54d04d84de1389c3a7170c8d92f16c
4
+ data.tar.gz: ccb3fd47554c553ec486bda99d5f6d4dd8814841
5
5
  SHA512:
6
- metadata.gz: 66e09ecc7cb06fd5106391f8ec7254fe91f82734b2e55812661eb55c4119338ebd3c00633ab903fcfe233c14db52acb005d9577cbe24ddfb6fc2021bc2edd9b7
7
- data.tar.gz: ad30ee43b319c8f13bcb4157cc044cff5fdd23e6131e9714e2d9df6ade6c887f04055caeb015f9cd8778d7a5bc8e274c81fe94b2713b3d623155e64e0c805204
6
+ metadata.gz: 335f64716495f041b884caed43b2e5046186f314136d6676ba6abe67bce1c5879240651d110a6cd704d37c0d804cc8ec2077b99beb67e6c691c07d140036bec4
7
+ data.tar.gz: f9ec4e0f024f55031f7d799461fabbc08430fb5de588c90d2ffae80767d5d6bad43cd67cfaaee54316990af6ad8a5d65498a3780479f927d36ffd41070429be3
@@ -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
- associations = self.parse_associations_attributes(:update)
45
- data.merge!(:associations => self.parse_associations_attributes(:update)) if associations.present?
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[:except].present?
76
- except = Array.wrap(self.item.recorder_options[:except])
77
- attributes.symbolize_keys.except(*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
 
@@ -3,7 +3,7 @@ module Recorder
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 11
6
+ TINY = 12
7
7
  PRE = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov