lib/active_wrapper/mail.rb in winton-active_wrapper-0.1.6 vs lib/active_wrapper/mail.rb in winton-active_wrapper-0.1.7
- old
+ new
@@ -3,24 +3,24 @@
attr_reader :base, :env, :config
def initialize(options)
@base = options[:base]
+ @config = {}
@env = options[:env].to_s
path = "#{base}/config/mail.yml"
if @env == 'test'
ActionMailer::Base.delivery_method = :test
else
@config[:smtp] = options[:smtp]
@config[:imap] = options[:imap]
if File.exists?(path)
- @config = YAML::load(File.open(path))
- if @config && @config = @config[@env]
- @config = @config.to_options
- @config[:imap] = @config[:imap].to_options unless @config[:imap]
- @config[:smtp] = @config[:smtp].to_options unless @config[:smtp]
+ yaml = YAML::load(File.open(path))
+ if yaml && yaml = yaml[@env].to_options
+ @config[:imap] = yaml[:imap].to_options unless @config[:imap]
+ @config[:smtp] = yaml[:smtp].to_options unless @config[:smtp]
end
end
if @config[:smtp]
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = @config[:smtp]
\ No newline at end of file