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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rack/contrib/mailexceptions.rb', line 24 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.
22 23 24 |
# File 'lib/rack/contrib/mailexceptions.rb', line 22 def config @config end |
Instance Method Details
#call(env) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rack/contrib/mailexceptions.rb', line 44 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
72 73 74 |
# File 'lib/rack/contrib/mailexceptions.rb', line 72 def disable_test_mode @test_mode = false end |
#enable_test_mode ⇒ Object
68 69 70 |
# File 'lib/rack/contrib/mailexceptions.rb', line 68 def enable_test_mode @test_mode = true end |
#smtp(settings = {}) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/rack/contrib/mailexceptions.rb', line 60 def smtp(settings={}) if settings @config[:smtp].merge! settings else @config[:smtp] = nil end end |