effective_logging 3.0.2 → 3.0.7

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
  SHA256:
3
- metadata.gz: c92ea369d5e7b887728bf0291ae1646927cec17e34291a6f992113974709d251
4
- data.tar.gz: c548c740c30f16808a9a4c3819de0e59f1c13f19a2d0e3c4731d98bde5a24554
3
+ metadata.gz: dc9fced444e21c7fe1cdfc6eefbb7a4a1c5aefde46e660c80ea8e556e4811a53
4
+ data.tar.gz: '02657769444b4e41d0fd0fa0ecd1d083aa5e60b7ba49df2f64be18d70e434404'
5
5
  SHA512:
6
- metadata.gz: fdbe98db9ef7b04d6b026fb2a440fe190836f971af7415c32b7ad653f35575a0bc1c0e635e5a9787d4a7e1a61dc9184741ca6af4615bd1ab594139720a1d9675
7
- data.tar.gz: fa25ce65060c2c38f575b90378da8962e6c53ab24708cbfdbd56b5ab13040c4c83b6ff69311ccf02cdc8919d5e9e4431ad55673260d865eb14d274067a941e5a
6
+ metadata.gz: 01efee520769124bc69f458c9db6301a3c9413ea43da4fae9b74cebf5b387a951828a058256c26db99926eb8a89851cfda74f85d879c90809586e3284c1503de
7
+ data.tar.gz: ed09985141339c9fe27f9f377bf84ed8e4c0e902609f0eddb493d235f9fc0ee78812cb7afd97592a4ff3c83fe3a0c0e281b9feb706f136360d253f2dd57c7093
@@ -1,7 +1,7 @@
1
1
  module ActsAsLoggable
2
2
  extend ActiveSupport::Concern
3
3
 
4
- module ActiveRecord
4
+ module Base
5
5
  def log_changes(*options)
6
6
  @acts_as_loggable_options = options.try(:first) || {}
7
7
 
@@ -8,13 +8,12 @@ module Effective
8
8
  attr_accessor :prev_log
9
9
 
10
10
  # Self-Referencing relationship
11
- belongs_to :parent, class_name: 'Effective::Log', counter_cache: true
11
+ belongs_to :parent, class_name: 'Effective::Log', counter_cache: true, optional: true
12
12
  has_many :logs, class_name: 'Effective::Log', foreign_key: :parent_id
13
13
 
14
- belongs_to :user
15
-
16
- belongs_to :changes_to, polymorphic: true # This is the log_changes to: option
17
- belongs_to :associated, polymorphic: true
14
+ belongs_to :user, optional: true
15
+ belongs_to :changes_to, polymorphic: true, optional: true # This is the log_changes to: option
16
+ belongs_to :associated, polymorphic: true, optional: true
18
17
 
19
18
  serialize :details, Hash
20
19
 
@@ -44,6 +43,10 @@ module Effective
44
43
  "Log #{id}"
45
44
  end
46
45
 
46
+ def associated_to_s=(value)
47
+ super(value.to_s[0...255].presence) # Take only first 255 characters
48
+ end
49
+
47
50
  def log(message, status = EffectiveLogging.statuses.first, options = {})
48
51
  EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
49
52
  end
@@ -5,16 +5,17 @@ module EffectiveLogging
5
5
  BLANK = "''"
6
6
  BLACKLIST = [:updated_at, :created_at, :encrypted_password, :status_steps] # Don't log changes or attributes
7
7
 
8
- def initialize(object, to: nil, prefix: nil, only: nil, except: nil)
8
+ # to, prefix, only, except
9
+ def initialize(object, args = {})
9
10
  @object = object
10
11
  @resource = Effective::Resource.new(object)
11
12
 
12
13
  # Validate changes_to value
13
- if to.present? && !@resource.belong_tos.map(&:name).include?(to)
14
- raise ArgumentError.new("unable to find existing belongs_to relationship matching #{to}. Expected a symbol matching a belongs_to.")
14
+ if args[:to].present? && !@resource.belong_tos.map(&:name).include?(args[:to])
15
+ raise ArgumentError.new("unable to find existing belongs_to relationship matching #{args[:to]}. Expected a symbol matching a belongs_to.")
15
16
  end
16
17
 
17
- @options = { to: to, prefix: prefix, only: only, except: Array(except) + BLACKLIST }.compact
18
+ @options = { to: args[:to], prefix: args[:prefix], only: args[:only], except: Array(args[:except]) + BLACKLIST }.compact
18
19
  end
19
20
 
20
21
  # Effective::Log.where(message: 'Deleted').where('details ILIKE ?', '%lab_test_id: 263%')
@@ -22,7 +22,7 @@ module EffectiveLogging
22
22
  # Include acts_as_loggable concern and allow any ActiveRecord object to call it with log_changes()
23
23
  initializer 'effective_logging.active_record' do |app|
24
24
  ActiveSupport.on_load :active_record do
25
- ActiveRecord::Base.extend(ActsAsLoggable::ActiveRecord)
25
+ ActiveRecord::Base.extend(ActsAsLoggable::Base)
26
26
  end
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '3.0.2'.freeze
2
+ VERSION = '3.0.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: 3.0.2
4
+ version: 3.0.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: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.0.3
141
+ rubygems_version: 3.1.2
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Automatically log all sent emails, user logins, and page views. This also