effective_logging 1.10.6 → 1.10.7

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: 4505eb9d63d37917638f060aa88ec3bba0ab1eb7
4
- data.tar.gz: 7003902e81dc178bd313135f9a199413380a98ef
3
+ metadata.gz: d829635a3ee649017e547dee63b92aa3971493b3
4
+ data.tar.gz: 8f515ec5922a6e4861394bd426e7608d3cfcde88
5
5
  SHA512:
6
- metadata.gz: 022241e504a0616086c903a81dbac1d127ff1f9565a7a1d44338dc6207c061ea5e57fb6d15f08404621ee61b00399ddfed4c2f1f4b0639369e36f45301e62f54
7
- data.tar.gz: 286cec2bbe861908b2f6279b404342ca145ede8733b5a80e77bd6dc9b39fe3eb5caa6f80ac18815a056511da2358263312649bf032588e8d03a3c306c750d04f
6
+ metadata.gz: 9c00de12b0954fa2372fa5b5cd6753781044bb992499a543035e218a6db85bf43363a52369c6052726496450e1b40a75bcd819cd64552b521a44d283eb2a5c34
7
+ data.tar.gz: 9cb295a0bc4c563ddb4262dc37728151767a395773124e5d9c5146af1b116bb9c09ff5317960501034d97bf059dc76af50f0e3e60671e93d53918e33fc662f20
@@ -21,9 +21,10 @@ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
21
21
  end
22
22
 
23
23
  unless attributes[:log_changes]
24
- col :associated_type, search: { as: :string }, visible: false
25
- col :associated_id, search: { as: :integer }, visible: false, label: 'Associated Id'
26
- col :associated_to_s, search: { as: :string }, label: 'Associated'
24
+ col :associated
25
+ #col :associated_type, search: { as: :string }, visible: false
26
+ #col :associated_id, search: { as: :integer }, visible: false, label: 'Associated Id'
27
+ #col :associated_to_s, search: { as: :string }, label: 'Associated'
27
28
  end
28
29
 
29
30
  col :message do |log|
@@ -18,7 +18,11 @@ module ActsAsLoggable
18
18
 
19
19
  around_save do |_, block|
20
20
  @acts_as_loggable_new_record = new_record?
21
- EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).changed! unless @acts_as_loggable_new_record
21
+
22
+ unless @acts_as_loggable_new_record
23
+ @acts_as_loggable_update_record = EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).changed!
24
+ end
25
+
22
26
  block.call
23
27
  true
24
28
  end
@@ -32,7 +36,7 @@ module ActsAsLoggable
32
36
  after_commit do
33
37
  if @acts_as_loggable_new_record
34
38
  EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).created!
35
- elsif !@acts_as_loggable_destroy_record
39
+ elsif !@acts_as_loggable_destroy_record && @acts_as_loggable_update_record
36
40
  EffectiveLogging::ActiveRecordLogger.new(self, log_changes_options).updated!
37
41
  end
38
42
 
@@ -51,6 +51,9 @@ module EffectiveLogging
51
51
  after = object.log_changes_formatted_value(attribute, after) || after
52
52
  end
53
53
 
54
+ before = before.to_s if before.kind_of?(ActiveRecord::Base)
55
+ after = after.to_s if after.kind_of?(ActiveRecord::Base)
56
+
54
57
  attribute = if object.respond_to?(:log_changes_formatted_attribute)
55
58
  object.log_changes_formatted_attribute(attribute)
56
59
  end || attribute.titleize
@@ -66,18 +69,25 @@ module EffectiveLogging
66
69
  ActiveRecordLogger.new(child, options.merge(logger: logger, depth: (depth + 1), prefix: "#{title} ##{index+1}: ")).execute!
67
70
  end
68
71
  end
72
+
73
+ @logged == true
69
74
  end
70
75
 
71
76
  private
72
77
 
73
78
  def log(message, details: {})
74
- logger.logged_changes.build(
79
+ @logged = true
80
+
81
+ log = logger.logged_changes.build(
75
82
  user: EffectiveLogging.current_user,
76
83
  status: EffectiveLogging.log_changes_status,
77
84
  message: "#{"\t" * depth}#{options[:prefix]}#{message}",
78
85
  associated_to_s: (logger.to_s rescue nil),
79
86
  details: details
80
- ).tap { |log| log.save }
87
+ )
88
+
89
+ log.save
90
+ log
81
91
  end
82
92
 
83
93
  # TODO: Make this work better with nested objects
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.10.6'.freeze
2
+ VERSION = '1.10.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.6
4
+ version: 1.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails