triggerable 0.1.6 → 0.1.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: d760b055f2a6dca80d03f71a2ab1ac64ae136e46
4
- data.tar.gz: 56240570bea8667aa0e539362d50b26553da5db0
3
+ metadata.gz: 01cc155d845bc2afb7c7eb308113e74819a00d4f
4
+ data.tar.gz: 81074d512740a11417bc35480d4ffc1e3192dfef
5
5
  SHA512:
6
- metadata.gz: 41360349dc159a7d3b37685ad102d49c90923d00e913276255fe644b25db32e3d13dfa0b35ab5af03029d4a57a085dd3e04e83bd46cfc2fc8a2170998a2fb107
7
- data.tar.gz: 52dcfd7ceadc96185c90d81b6ac7a23441f6ee0cd9d9645354fe55dc26d01f642a30c6d03847a87d08068a23bf6c81febba4c167fae190cac0e91b17db0e08f1
6
+ metadata.gz: 01af1a6893ed82e2878e57ab66578c6b05f5dae25eb822faf06ba66faf5071af0329b0ab266a306b0ef2b2a4b39b7b0e75d0b40f7f8651009ae4de3efffe70ee
7
+ data.tar.gz: e0d69053d213d38377dcaa496ded6d51cbc630933f2e623ba79a0d53b384037dc1db94a94b3c657d1d9566f4682b1d2b4ac7bf3dab085c5746d5fa4ac3978b00
data/README.md CHANGED
@@ -24,7 +24,7 @@ Setup and defining trigger and automation:
24
24
 
25
25
  ```ruby
26
26
  class User < ActiveRecord::Base
27
- trigger on: :after_create, if: { receives_sms: true }, do
27
+ trigger on: :after_create, if: { receives_sms: true } do
28
28
  user.send_welcome_sms
29
29
  end
30
30
 
@@ -22,9 +22,19 @@ module Triggerable
22
22
  def run_for! object, trigger_name
23
23
  proc = @block
24
24
  object.instance_eval do
25
- PaperTrail.whodunnit = trigger_name if defined?(PaperTrail)
26
- instance_exec(&proc)
27
- PaperTrail.whodunnit = nil if defined?(PaperTrail)
25
+ change_whodunnit = trigger_name.present? && defined?(PaperTrail)
26
+ old_whodunnit = nil
27
+
28
+ if change_whodunnit
29
+ old_whodunnit = PaperTrail.whodunnit
30
+ PaperTrail.whodunnit = trigger_name
31
+ end
32
+
33
+ begin
34
+ instance_exec(&proc)
35
+ ensure
36
+ PaperTrail.whodunnit = old_whodunnit if change_whodunnit
37
+ end
28
38
  end
29
39
  end
30
40
  end
@@ -1,3 +1,3 @@
1
1
  module Triggerable
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triggerable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler