Class: Emailer::LoggerSmtpFacade
- Inherits:
-
MockSmtpFacade
- Object
- SmtpFacade
- MockSmtpFacade
- Emailer::LoggerSmtpFacade
- Defined in:
- lib/emailer/logger_smtp_facade.rb
Instance Attribute Summary
Attributes inherited from MockSmtpFacade
Attributes inherited from SmtpFacade
#error, #offending_mail, #settings
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ LoggerSmtpFacade
constructor
A new instance of LoggerSmtpFacade.
- #open ⇒ Object
-
#send_mail(options) ⇒ Object
And save, don’t send, write to a singel file.
Methods inherited from MockSmtpFacade
#get_net_smtp_instance, #get_url_for, #last_email_sent, #last_email_sent_key, #last_email_sent_url
Methods inherited from SmtpFacade
#get_net_smtp_instance, #send_html, #send_text
Constructor Details
#initialize(settings = {}) ⇒ LoggerSmtpFacade
Returns a new instance of LoggerSmtpFacade.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/emailer/logger_smtp_facade.rb', line 5 def initialize(settings = {}) @logger_settings = settings.clone @logger_settings.keys.each do |key| raise ArgumentError.new("invalid option, {"+key.to_s+" => "+@logger_settings[key].to_s+"}") unless [:log_file, :use].include? key end raise ArgumentError.new(":log_file location is missing") unless @logger_settings[:log_file] settings.clear super end |
Instance Method Details
#open ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/emailer/logger_smtp_facade.rb', line 16 def open if @logger_settings[:use] @logger_settings[:use].open do super end else super end end |
#send_mail(options) ⇒ Object
And save, don’t send, write to a singel file
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/emailer/logger_smtp_facade.rb', line 27 def send_mail() super @logger_settings[:use].send_mail if @logger_settings[:use] File.open(@logger_settings[:log_file],File::WRONLY|File::APPEND|File::CREAT) do |f| f.print "email.add {\n" .each do |option| f.print "\t:"+option.first.to_s+" => \""+option.last.to_s+"\"\n" unless option.first == :body end f.print "\t:sent_at => \""+Time.now.to_s+"\"\n" f.print "\t:body => \""+[:body].to_s+"\"\n" f.print "}\n" end end |