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.
9 10 11 12 13 |
# File 'lib/ditty/emails/base.rb', line 9 def initialize( = {}) @mail = [:mail] || Mail.new @locals = [:locals] || {} @options = .merge end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
25 26 27 28 |
# File 'lib/ditty/emails/base.rb', line 25 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.
7 8 9 |
# File 'lib/ditty/emails/base.rb', line 7 def locals @locals end |
#mail ⇒ Object
Returns the value of attribute mail.
7 8 9 |
# File 'lib/ditty/emails/base.rb', line 7 def mail @mail end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/ditty/emails/base.rb', line 7 def @options end |
Class Method Details
.deliver!(to = nil, options = {}) ⇒ Object
67 68 69 70 |
# File 'lib/ditty/emails/base.rb', line 67 def deliver!(to = nil, = {}) locals = [:locals] || {} new().deliver!(to, locals) end |
Instance Method Details
#deliver!(to = nil, locals = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ditty/emails/base.rb', line 15 def deliver!(to = nil, locals = {}) [:to] = to unless to.nil? @locals.merge!(locals) %i[to from subject].each do |param| mail.send(param, [param]) if [param] end mail.body content mail.deliver! end |
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
30 31 32 |
# File 'lib/ditty/emails/base.rb', line 30 def respond_to_missing?(method, _include_private = false) mail.respond_to? method end |