Module: Hanami::Mailer::Dsl
- Defined in:
- lib/hanami/mailer/dsl.rb
Overview
Class level DSL
Class Method Summary collapse
- .extended(base) ⇒ Object private
Instance Method Summary collapse
-
#bcc(value = nil) ⇒ Object
Sets the bcc (blind carbon copy) for mail messages.
-
#cc(value = nil) ⇒ Object
Sets the cc (carbon copy) for mail messages.
-
#from(value = nil) ⇒ Object
Sets the sender for mail messages.
-
#reply_to(value = nil) ⇒ Object
Sets the reply_to for mail messages.
-
#return_path(value = nil) ⇒ Object
Sets the MAIL FROM address 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.
Class Method Details
.extended(base) ⇒ Object
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.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hanami/mailer/dsl.rb', line 14 def self.extended(base) base.class_eval do @from = nil @to = nil @cc = nil @bcc = nil @reply_to = nil @return_path = nil @subject = nil end end |
Instance Method Details
#bcc(value) ⇒ NilClass #bcc ⇒ String, ...
Sets the bcc (blind carbon copy) 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 is optional.
When a value is given, it specifies the bcc for the email. When a value is not given, it returns the bcc 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.
375 376 377 378 379 380 381 |
# File 'lib/hanami/mailer/dsl.rb', line 375 def bcc(value = nil) if value.nil? @bcc else @bcc = value end end |
#cc(value) ⇒ NilClass #cc ⇒ String, ...
Sets the cc (carbon copy) 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 is optional.
When a value is given, it specifies the cc for the email. When a value is not given, it returns the cc 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.
286 287 288 289 290 291 292 |
# File 'lib/hanami/mailer/dsl.rb', line 286 def cc(value = nil) if value.nil? @cc else @cc = value end end |
#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.
197 198 199 200 201 202 203 |
# File 'lib/hanami/mailer/dsl.rb', line 197 def from(value = nil) if value.nil? @from else @from = value end end |
#reply_to(value) ⇒ NilClass #reply_to ⇒ String, ...
Sets the reply_to 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 is optional.
When a value is given, it specifies the reply_to for the email. When a value is not given, it returns the reply_to 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.
464 465 466 467 468 469 470 |
# File 'lib/hanami/mailer/dsl.rb', line 464 def reply_to(value = nil) if value.nil? @reply_to else @reply_to = value end end |
#return_path(value) ⇒ NilClass #return_path ⇒ String, Symbol
Sets the MAIL FROM address for mail messages. This lets you specify a “bounce address” different from the sender address specified with ‘from`.
It accepts a hardcoded value as a string, or a symbol that represents an instance method for more complex logic.
This value is optional.
When a value is given, specify the MAIL FROM address of the email Otherwise, it returns the MAIL FROM address 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.
141 142 143 144 145 146 147 |
# File 'lib/hanami/mailer/dsl.rb', line 141 def return_path(value = nil) if value.nil? @return_path else @return_path = 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.
606 607 608 609 610 611 612 |
# File 'lib/hanami/mailer/dsl.rb', line 606 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.
58 59 60 61 62 63 64 |
# File 'lib/hanami/mailer/dsl.rb', line 58 def template(value = nil) if value.nil? @template ||= ::Hanami::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.
84 85 86 87 88 89 90 |
# File 'lib/hanami/mailer/dsl.rb', line 84 def templates(format = nil) if format.nil? @templates = ::Hanami::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.
550 551 552 553 554 555 556 |
# File 'lib/hanami/mailer/dsl.rb', line 550 def to(value = nil) if value.nil? @to else @to = value end end |