Module: Lotus::Mailer::Dsl
- Defined in:
- lib/lotus/mailer/dsl.rb
Overview
Class level DSL
Instance Method Summary collapse
-
#from(value = nil) ⇒ Object
Sets the sender for mail messages.
-
#subject(value = nil) ⇒ Object
Sets the subject for mail messages.
-
#template(value = nil) ⇒ Object
Set the template name IF it differs from the convention.
-
#templates(format = nil) ⇒ Object
private
Returns a set of associated templates or only one for the given format.
-
#to(value = nil) ⇒ Object
Sets the recipient for mail messages.
Instance Method Details
#from(value) ⇒ NilClass #from ⇒ String, Symbol
Sets the sender for mail messages
It accepts a hardcoded value as a string, or a symbol that represents an instance method for more complex logic.
This value MUST be set, otherwise an exception is raised at the delivery time.
When a value is given, specify the sender of the email Otherwise, it returns the sender of the email
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding class variable. When called without, it will return the already set value, or the default.
124 125 126 127 128 129 130 |
# File 'lib/lotus/mailer/dsl.rb', line 124 def from(value = nil) if value.nil? @from else @from = value end end |
#subject(value) ⇒ NilClass #subject ⇒ String, Symbol
Sets the subject for mail messages
It accepts a hardcoded value as a string, or a symbol that represents an instance method for more complex logic.
This value MUST be set, otherwise an exception is raised at the delivery time.
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding class variable. When called without, it will return the already set value, or the default.
266 267 268 269 270 271 272 |
# File 'lib/lotus/mailer/dsl.rb', line 266 def subject(value = nil) if value.nil? @subject else @subject = value end end |
#template(value) ⇒ NilClass #template ⇒ String
Set the template name IF it differs from the convention.
For a given mailer named Signup::Welcome
it will look for signup/welcome..
templates under the root directory.
If for some reason, we need to specify a different template name, we can use this method.
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding class variable. When called without, it will return the already set value, or the default.
42 43 44 45 46 47 48 |
# File 'lib/lotus/mailer/dsl.rb', line 42 def template(value = nil) if value.nil? @template ||= ::Lotus::Mailer::Rendering::TemplateName.new(name, configuration.namespace).to_s else @template = value end end |
#templates(format) ⇒ Hash #templates ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a set of associated templates or only one for the given format
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding class variable. When called without, it will return the already set value, or the default.
68 69 70 71 72 73 74 |
# File 'lib/lotus/mailer/dsl.rb', line 68 def templates(format = nil) if format.nil? @templates = ::Lotus::Mailer::Rendering::TemplatesFinder.new(self).find else @templates.fetch(format, nil) end end |
#to(value) ⇒ NilClass #to ⇒ String, ...
Sets the recipient for mail messages
It accepts a hardcoded value as a string or array of strings. For dynamic values, you can specify a symbol that represents an instance method.
This value MUST be set, otherwise an exception is raised at the delivery time.
When a value is given, specify the recipient of the email Otherwise, it returns the recipient of the email
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding class variable. When called without, it will return the already set value, or the default.
210 211 212 213 214 215 216 |
# File 'lib/lotus/mailer/dsl.rb', line 210 def to(value = nil) if value.nil? @to else @to = value end end |