module Ditty::Services::Email
Attributes
config[W]
Public Class Methods
config!()
click to toggle source
# File lib/ditty/services/email.rb, line 16 def config! cfg = config Mail.defaults do delivery_method cfg[:delivery_method].to_sym, (cfg[:options] || {}) end end
deliver(email, to = nil, options = {})
click to toggle source
# File lib/ditty/services/email.rb, line 31 def deliver(email, to = nil, options = {}) generate(email, to, options).deliver! end
generate(email, to = nil, options = {})
click to toggle source
# File lib/ditty/services/email.rb, line 23 def generate(email, to = nil, options = {}) config! options[:to] ||= to unless to.nil? options[:from] ||= config[:from] unless config[:from].nil? email = from_symbol(email, options) if email.is_a? Symbol email end
Private Class Methods
config()
click to toggle source
# File lib/ditty/services/email.rb, line 37 def config @config ||= default.merge ::Ditty::Services::Settings.values(:email) || {} end
default()
click to toggle source
# File lib/ditty/services/email.rb, line 41 def default { delivery_method: :logger, logger: ::Ditty::Services::Logger } end
from_symbol(email, options)
click to toggle source
# File lib/ditty/services/email.rb, line 48 def from_symbol(email, options) require "ditty/emails/#{email}" constantize("Ditty::Emails::#{classify(email)}").new(options) end