Class: Rack::MailExceptions
- Inherits:
-
Object
- Object
- Rack::MailExceptions
- Defined in:
- lib/rack/contrib/mailexceptions.rb
Overview
use smtp
use Rack::MailExceptions do |mail|
mail.to '[email protected]'
mail.smtp :address => 'mail.test.com', :user_name => '[email protected]', :password => 'test'
end
use sendmail
use Rack::MailExceptions do |mail|
mail.to '[email protected]'
mail.smtp false
end
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #disable_test_mode ⇒ Object
- #enable_test_mode ⇒ Object
-
#initialize(app) {|_self| ... } ⇒ MailExceptions
constructor
A new instance of MailExceptions.
- #smtp(settings = {}) ⇒ Object
Constructor Details
#initialize(app) {|_self| ... } ⇒ MailExceptions
Returns a new instance of MailExceptions.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rack/contrib/mailexceptions.rb', line 26 def initialize(app) @app = app @config = { :to => nil, :from => ENV['USER'] || 'rack@localhost', :subject => '[exception] %s', :smtp => { :address => 'localhost', :domain => 'localhost', :port => 25, :authentication => :login, :user_name => nil, :password => nil } } @template = ERB.new(TEMPLATE) @test_mode = false yield self if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
24 25 26 |
# File 'lib/rack/contrib/mailexceptions.rb', line 24 def config @config end |
Instance Method Details
#call(env) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rack/contrib/mailexceptions.rb', line 46 def call(env) status, headers, body = begin @app.call(env) rescue => boom send_notification boom, env raise end send_notification env['mail.exception'], env if env['mail.exception'] [status, headers, body] end |
#disable_test_mode ⇒ Object
74 75 76 |
# File 'lib/rack/contrib/mailexceptions.rb', line 74 def disable_test_mode @test_mode = false end |
#enable_test_mode ⇒ Object
70 71 72 |
# File 'lib/rack/contrib/mailexceptions.rb', line 70 def enable_test_mode @test_mode = true end |
#smtp(settings = {}) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/rack/contrib/mailexceptions.rb', line 62 def smtp(settings={}) if settings @config[:smtp].merge! settings else @config[:smtp] = nil end end |