Module: Ditty::Services::Email
- Extended by:
- ActiveSupport::Inflector
- Defined in:
- lib/ditty/services/email.rb
Class Attribute Summary collapse
-
.config ⇒ Object
writeonly
Sets the attribute config.
Class Method Summary collapse
- .config! ⇒ Object
- .deliver(email, to = nil, options = {}) ⇒ Object
- .generate(email, to = nil, options = {}) ⇒ Object
Class Attribute Details
.config=(value) ⇒ Object
Sets the attribute config
14 15 16 |
# File 'lib/ditty/services/email.rb', line 14 def config=(value) @config = value end |
Class Method Details
.config! ⇒ Object
16 17 18 19 20 21 |
# 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 = {}) ⇒ Object
31 32 33 |
# File 'lib/ditty/services/email.rb', line 31 def deliver(email, to = nil, = {}) generate(email, to, ).deliver! end |
.generate(email, to = nil, options = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/ditty/services/email.rb', line 23 def generate(email, to = nil, = {}) config! [:to] ||= to unless to.nil? [:from] ||= config[:from] unless config[:from].nil? email = from_symbol(email, ) if email.is_a? Symbol email end |