notifiably_audited 1.0.0 → 1.0.1

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjgwODlmMThlYzhiN2NjYzAwZjk2YmJmNDcwNDIxMTkyNjFiOTVhYw==
4
+ ZWJjYTgyYzAzZmNhNzAyMmEyNTYxN2U3YWM2MWUxMDcwMmNjNGFkYw==
5
5
  data.tar.gz: !binary |-
6
- NzQyNTE4M2EwMzkzNGM5MmI5NzYwY2FlMWIwYWJjOTMyOWRiMDFkMw==
6
+ NWM4YzA2OWE2OTlmMDE4ZTI3NTQ2YWYwNTAxNmZkNDA1YTc0ODM3OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWY0MDA3NGRhY2ZmYWViZWE2YmQxYWQ0YzY2MTJhMTRjZjU0Mzc0MjQ2MTIz
10
- MmEwNmNhZjllOWE0NzM3M2JiYWI2MmNmOTAwNjAxYThkZjcxZmUzZDFhMDU5
11
- YjUzMDk1YjVjOWFjYzMwYWQwN2NhNTM5Mzg0MGJiZmNmNzFlMDI=
9
+ YTIzOGMxNzBkNWQyOTYyODQxYzk1YTlhMzg2ZDZkNGU0MzlmZDFjYTk1YTdh
10
+ ZmNjMjhiZDAxMTZhZTQwOGIzY2M4ZjY5MjUwYjA0NDIyOGY1MDZhNGY3NTI2
11
+ ZjRlN2FhNDU5N2E2MmYwMGU5MzVkMDIzMzMwNzU0MGM1Y2RhN2E=
12
12
  data.tar.gz: !binary |-
13
- NTllMTFhM2YwODNlNTllMmNhMWIxMGZiN2Y2MDA0M2NiZjNhYWEzZGRjMDNj
14
- MTQyMmE0N2E1OWU5OTBlNThlMjEyNjc4NTdjMDFjZTYzZTVjYjQ4YjMyZmRl
15
- YzU5NzYzNmMzMWRhOWU3OGM1NmM3ZmEwZDg4ZjA2NGQ5NTgwMjU=
13
+ ZjhiNTU4ZjhlNjk1MjdlNTYzNDc5MjVkOGMyNjMyM2E4ZGE3ZjhiM2JjNjFi
14
+ MWJmOTBiZGE0ODFmMWJkODc4YzcyZTBhMGM0MjM4ODMzMGE1MmVjMGVmNmY1
15
+ YTYwOGUwMmRiNzY3ZTg1MTc0YWQzNzQzNzQ1NDE2NDY5YTE4ZGI=
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'notifiably_audited-activerecord'
5
- gem.version = '1.0.0'
5
+ gem.version = '1.0.1'
6
6
 
7
7
  gem.authors = ['senthil kumar']
8
8
  gem.email = 'senthilkumar.hce@gmail.com'
data/audited.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'notifiably_audited'
5
- gem.version = '1.0.0'
5
+ gem.version = '1.0.1'
6
6
 
7
7
  gem.authors = ['senthil kumar']
8
8
  gem.email = 'senthilkumar.hce@gmail.com'
@@ -377,8 +377,10 @@ module NotifiablyAudited
377
377
  @audit_values[:title] = opts[1]
378
378
  @audit_values[:comment] = opts[2]
379
379
  # if 3rd argument is present in the opts, then overriding title
380
+ # this is a little bit of a complicated option. If you mean that the specified column in [0], has to be only one column, contains an id of an object referenced by the [:model,:field_name] in [3], then go ahead and append it in the title.
381
+ # If the [3] is not an array but a single symbol, then fetch its value from the current object and append
380
382
  if opts[3].present?
381
- append = opts[3][0].to_s.camelize.constantize.find(self.send(opts[0][0])).send(opts[3][1])
383
+ to_append = decide_append(opts[0][0],opts[3])
382
384
  @audit_values[:title] = @audit_values[:title] + "[#{append}]"
383
385
  end
384
386
  # actual recording of audit
@@ -387,6 +389,18 @@ module NotifiablyAudited
387
389
  @non_monitor = 0
388
390
  end
389
391
  end
392
+
393
+ def decide_append(zero,three)
394
+ if three.kind_of?(Array)
395
+ append = three[0].to_s.camelize.constantize.find(self.send(zero)).send(three[1])
396
+ elsif three.kind_of?(Symbol)
397
+ append = self.send(three)
398
+ else
399
+ errors.add(:audit_comment, "The 3rd argument for a specific alert_for item should either be an array of [:model,:field_name] or a symbol of current object's :field_name ")
400
+ return false
401
+ end
402
+ append
403
+ end
390
404
  #========================================
391
405
 
392
406
  def write_audit(attrs)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiably_audited
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - senthil kumar