logga 0.4.7 → 0.5.0

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: 4db09ecb1d0903c4112d3665b545f06bd284db39
4
- data.tar.gz: c996310246f0227cc88bceca0a66075ba2ef5a79
3
+ metadata.gz: 90ad8c80a8ecf201d47feabd056cf8db08a42d92
4
+ data.tar.gz: c6fb3e1abb33d4bf16ebe22e0036314b6d2d9773
5
5
  SHA512:
6
- metadata.gz: b8d45abd6756764741ea9a07edb30642d588dedf48c3e862d3b2ff0ab55232d94a67bd5dce9b288f0b4b02cd599daaaa6d4ff15395abb1328a4b9fad10300020
7
- data.tar.gz: 2b8da5e07e063d65e20d7a44cff2dbb8c27c8892e4ea901ca3e991525fcc5930aada9c6a9cbc62e6ade361d7bb78a30683d58bfb6fd345d3692d449031ff0424
6
+ metadata.gz: 2702013ce3ab3e0a7f8dd5e85b0123514d8f2bff78e24481b2eef5af4654fce2adc83f1ff64dc5f38fd02a344ef46460325696670bed68e03491026802104a4a
7
+ data.tar.gz: c7204f2cee01d6afd335c6cabc702b06eb034f01706feb918be4cd9454c860c6a86ae43f2e9c03bed84aadb8fc8df472476bd0c4470c71ca001e20ba0a197510
@@ -6,17 +6,20 @@ module Logga
6
6
  EXCLUDED_KEYS_SUFFIXES = [:_id, :_filenames]
7
7
 
8
8
  included do
9
- class_attribute :log_fields, instance_writer: false
10
- self.log_fields = {}
9
+ class_attribute :log_fields, instance_writer: false
10
+ class_attribute :excluded_fields, instance_writer: false
11
+ self.log_fields = {}
12
+ self.excluded_fields = {}
11
13
  end
12
14
 
13
15
  class_methods do
14
- def add_log_entries_for(*actions, to: :self, fields: {})
16
+ def add_log_entries_for(*actions, to: :self, fields: {}, exclude_fields: []
15
17
  after_create :log_model_creation if actions.include?(:create)
16
18
  after_destroy :log_model_deletion if actions.include?(:delete)
17
19
  after_update :log_model_changes if actions.include?(:update)
18
20
  define_method(:log_receiver) { to == :self ? self : send(to) }
19
- self.log_fields = fields
21
+ self.log_fields = fields
22
+ self.excluded_fields = Array(exclude_fields)
20
23
  end
21
24
  end
22
25
 
@@ -34,7 +37,8 @@ module Logga
34
37
 
35
38
  def log_model_changes
36
39
  field_changes = changes.reject do |k, _|
37
- EXCLUDED_KEYS.include?(k.to_sym) ||
40
+ excluded_fields.include?(k.to_sym) ||
41
+ EXCLUDED_KEYS.include?(k.to_sym) ||
38
42
  EXCLUDED_KEYS_SUFFIXES.any? { |suffix| k.to_s.end_with?(suffix.to_s) }
39
43
  end
40
44
  log_field_changes(field_changes)
data/lib/logga/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Logga
2
- VERSION = "0.4.7"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Chinery, Rob Hesketh, Lorenzo Tello