easy_mail 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/easy_mail/mailer.rb
CHANGED
@@ -9,6 +9,7 @@ module EasyMail
|
|
9
9
|
|
10
10
|
def initialize(name, attributes = {})
|
11
11
|
@name = name.to_s.split("/").pop
|
12
|
+
@template_name = attributes[:template_name] || "template"
|
12
13
|
|
13
14
|
if Rails.env.production?
|
14
15
|
@to = attributes[:to] || self.class.send_to
|
@@ -21,7 +22,6 @@ module EasyMail
|
|
21
22
|
end
|
22
23
|
|
23
24
|
@subject = attributes[:subject] || self.class.send_subject || "Please Read"
|
24
|
-
@template_name = attributes[:name]
|
25
25
|
@namespace = if self.class.namespaces.any?
|
26
26
|
(self.class.namespaces.last.name.split("/") + name.to_s.split("/").slice(0..-2)).map(&:classify).join("::")
|
27
27
|
else
|
@@ -65,7 +65,7 @@ module EasyMail
|
|
65
65
|
|
66
66
|
|
67
67
|
def template_path
|
68
|
-
["
|
68
|
+
["#{namespace.underscore}", "mail/#{name.tableize}"].select(&:present?).join("/")
|
69
69
|
end
|
70
70
|
|
71
71
|
def mail_controller
|
@@ -99,6 +99,8 @@ module EasyMail
|
|
99
99
|
def generate_controller
|
100
100
|
mailer = self
|
101
101
|
mail_controller.class_eval do
|
102
|
+
layout nil
|
103
|
+
|
102
104
|
define_method :show do
|
103
105
|
instance_variable_set("@#{mailer.name}", mailer.model_class.new)
|
104
106
|
end
|
@@ -107,11 +109,16 @@ module EasyMail
|
|
107
109
|
instance_variable_set("@#{mailer.name}", mailer.model_class.new(params[mailer.form_key]))
|
108
110
|
if instance_variable_get("@#{mailer.name}").valid?
|
109
111
|
mailer.mailer_class.send_mail(instance_variable_get("@#{mailer.name}")).deliver
|
110
|
-
|
112
|
+
|
113
|
+
redirect_to action: :confirmation
|
111
114
|
else
|
112
115
|
render :show
|
113
116
|
end
|
114
117
|
end
|
118
|
+
|
119
|
+
define_method :confirmation do
|
120
|
+
render "shared/mail/confirmation"
|
121
|
+
end
|
115
122
|
end
|
116
123
|
end
|
117
124
|
|
@@ -193,6 +200,7 @@ module EasyMail
|
|
193
200
|
def routes(router)
|
194
201
|
EasyMail::Mailer.all.each do |mailer|
|
195
202
|
router.get mailer.route_url, to: "#{mailer.route_to_controller_part}#show", as: mailer.route_as
|
203
|
+
router.get "#{mailer.route_url}/confirmation", to: "#{mailer.route_to_controller_part}#confirmation"
|
196
204
|
router.post mailer.route_url, to: "#{mailer.route_to_controller_part}#create"
|
197
205
|
end
|
198
206
|
end
|
data/lib/easy_mail/version.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
EasyMail::Mailer.setup(to: "", from: "", bcc: "", subject: "") do
|
1
|
+
EasyMail::Mailer.setup(to: "", from: "", bcc: "", subject: "Please Read") do
|
2
2
|
# new :contact
|
3
|
-
# new "store/contact",
|
3
|
+
# new "store/contact",
|
4
|
+
# to: "test@mail.com",
|
5
|
+
# from: "test@mail.com",
|
6
|
+
# bcc: "test@mail.com",
|
7
|
+
# subject: "Subject",
|
8
|
+
# template_name: "template"
|
4
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
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-11-
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: easy_validator
|