Sha256: 0645e3e418fa25ddf451d84a869f08ce6f0a44307c5a9c5fb1bb8be80ee35113
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
module ActiveWrapper class Mail attr_reader :base, :env, :config def initialize(options) @base = options[:base] @config = { :smtp => options[:smtp] || {}, :sendmail => options[:sendmail] || nil, :imap => options[:imap] || {} } @env = options[:env].to_s path = "#{base}/config/mail.yml" if File.exists?(path) yaml = YAML::load(File.open(path)) if yaml && yaml[@env] yaml = yaml[@env].to_options @config[:imap] = yaml[:imap].to_options if yaml[:imap] @config[:sendmail] = yaml[:sendmail] if !yaml[:sendmail].nil? @config[:smtp] = yaml[:smtp].to_options if yaml[:smtp] end end if @env == 'test' ActionMailer::Base.delivery_method = :test elsif @config[:sendmail] ActionMailer::Base.delivery_method = :sendmail elsif @config[:smtp] ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = @config[:smtp] end end def deliver(options) Mailer.deliver_email(options) end class Mailer < ::ActionMailer::Base def email(options) from options[:from] recipients options[:to] subject options[:subject] body options[:body] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_wrapper-0.3.3 | lib/active_wrapper/mail.rb |
active_wrapper-0.3.2 | lib/active_wrapper/mail.rb |
active_wrapper-0.3.1 | lib/active_wrapper/mail.rb |