disclosure 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,20 @@ module Disclosure
|
|
2
2
|
class EmailReactor < ActionMailer::Base
|
3
3
|
default Disclosure.configuration.email_reactor_defaults
|
4
4
|
|
5
|
-
def react!(model, action,
|
6
|
-
self.notification(model, action,
|
5
|
+
def react!(model, action, user)
|
6
|
+
self.notification(model, action, user).deliver
|
7
7
|
end
|
8
8
|
|
9
|
-
def notification(model, action,
|
9
|
+
def notification(model, action, user)
|
10
|
+
@model = model
|
11
|
+
@action = action
|
12
|
+
@user = user
|
13
|
+
@subject = t("disclosure.email_reactor.#{model.class.name.underscore}.#{action}.subject")
|
10
14
|
mail(
|
11
|
-
:to =>
|
12
|
-
:subject =>
|
13
|
-
:template_path => "disclosure/email/#{
|
14
|
-
:template_name =>
|
15
|
+
:to => @user.email,
|
16
|
+
:subject => @subject,
|
17
|
+
:template_path => "disclosure/email/#{model.class.name.underscore}",
|
18
|
+
:template_name => @action
|
15
19
|
)
|
16
20
|
end
|
17
21
|
end
|
@@ -9,12 +9,19 @@ module Disclosure
|
|
9
9
|
def self.instrument!
|
10
10
|
Disclosure.configuration.notifier_classes.each do |klass|
|
11
11
|
klass.class_eval do
|
12
|
-
|
12
|
+
around_save :notify_disclosure_with_save
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
|
16
|
+
def notify_disclosure_with_save
|
17
|
+
# Keep track of the original model to pick up changes properly
|
18
|
+
@model_before_save = self
|
19
|
+
|
20
|
+
# Call save, etc.
|
21
|
+
yield
|
22
|
+
|
23
|
+
# Send the notification with the original model
|
24
|
+
ActiveSupport::Notifications.instrument("disclosure.model_saved", :model => @model_before_save)
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
data/lib/disclosure/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disclosure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: 4604734519384497078
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash:
|
112
|
+
hash: 4604734519384497078
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 1.8.23
|