File tree Expand file tree Collapse file tree 6 files changed +28
-6
lines changed
Expand file tree Collapse file tree 6 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 22require "courrier/envelope"
33require "courrier/email"
44require "courrier/configuration"
5+ require "courrier/notifier"
56
67module Courrier
78 class << self
Original file line number Diff line number Diff line change 11module Courrier
22 class Configuration
33 attr_accessor :mailer
4+ attr_accessor :interceptor_email
45 end
56end
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ def self.subclass_by_email_name(email_name)
7070 end
7171
7272 def recipient
73- return Settings . interceptor_emails . first if Settings . interceptor_emails . any ?
73+ return Courrier . configuration . interceptor_email if Courrier . configuration . interceptor_email . present ?
7474 method = self . class . recipient_method
7575 raise Courrier ::RecipientUndefinedError . new ( "Please declare a recipient in #{ self . class . name } " ) if method . nil? || !self . respond_to? ( method , true )
7676 send ( method )
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ def deliver
1212 log "Delivering #{ email_name } to #{ recipient_email } "
1313 payload . tap do |args |
1414
15- case recipient
16- when User
15+ if emailable? ( recipient )
1716 Courrier . configuration . mailer . transactional_email_to_user ( *args )
1817 else
1918 Courrier . configuration . mailer . transactional_email_to_address ( *args )
@@ -35,8 +34,7 @@ def mailer
3534 end
3635
3736 def recipient_email
38- case recipient
39- when User
37+ if emailable? ( recipient )
4038 recipient . email
4139 else
4240 recipient
@@ -51,5 +49,9 @@ def log(info)
5149 Rails . logger . info "#{ self . class . name } -- #{ info } "
5250 end
5351
52+ def emailable? ( recipient )
53+ recipient . respond_to? :email
54+ end
55+
5456 end
5557end
Original file line number Diff line number Diff line change 1+ module Courrier
2+ module Notifier
3+ extend self
4+
5+ def deliver ( *args )
6+ Courrier ::Envelope . new ( *args ) . deliver
7+ end
8+
9+ # Plan to configure with an adapter and allow for async delivers
10+
11+ # def deliver_async(email_name, attributes)
12+ # end
13+ #
14+ # def deliver_in(interval, email_name, attributes)
15+ # end
16+
17+ end
18+ end
Original file line number Diff line number Diff line change 11module Courrier
2- VERSION = "0. 1.0"
2+ VERSION = "1.0.1 "
33end
You can’t perform that action at this time.
0 commit comments