Class: Ditty::Emails::Base
- Inherits:
-
Object
- Object
- Ditty::Emails::Base
- Defined in:
- lib/ditty/emails/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#locals ⇒ Object
Returns the value of attribute locals.
-
#mail ⇒ Object
Returns the value of attribute mail.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #deliver!(to = nil, locals = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 |
# File 'lib/ditty/emails/base.rb', line 11 def initialize( = {}) @mail = [:mail] || Mail.new @locals = [:locals] || {} = .merge end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/ditty/emails/base.rb', line 33 def method_missing(method, *args, &block) return super unless respond_to_missing?(method) mail.send(method, *args, &block) end |
Instance Attribute Details
#locals ⇒ Object
Returns the value of attribute locals.
9 10 11 |
# File 'lib/ditty/emails/base.rb', line 9 def locals @locals end |
#mail ⇒ Object
Returns the value of attribute mail.
9 10 11 |
# File 'lib/ditty/emails/base.rb', line 9 def mail @mail end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/ditty/emails/base.rb', line 9 def end |
Class Method Details
.deliver!(to = nil, options = {}) ⇒ Object
79 80 81 82 |
# File 'lib/ditty/emails/base.rb', line 79 def deliver!(to = nil, = {}) locals = [:locals] || {} new().deliver!(to, locals) end |
Instance Method Details
#deliver!(to = nil, locals = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ditty/emails/base.rb', line 17 def deliver!(to = nil, locals = {}) [:to] = to unless to.nil? @locals.merge!(locals) i[to from subject content_type].each do |param| next unless [param] @locals[param] ||= [param] mail.send(param, [param]) end html = content mail.html_part do body html end mail.deliver! end |
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
39 40 41 |
# File 'lib/ditty/emails/base.rb', line 39 def respond_to_missing?(method, _include_private = false) mail.respond_to? method end |