Class: Mailtime::MailTemplateCollection
- Inherits:
-
Object
- Object
- Mailtime::MailTemplateCollection
- Defined in:
- lib/mailtime/active_record/models/mail_template.rb
Instance Attribute Summary collapse
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(mail) ⇒ MailTemplateCollection
constructor
A new instance of MailTemplateCollection.
- #text ⇒ Object (also: #txt)
Constructor Details
#initialize(mail) ⇒ MailTemplateCollection
15 16 17 18 19 |
# File 'lib/mailtime/active_record/models/mail_template.rb', line 15 def initialize(mail) @mail = mail @templates = Mailtime::MailTemplate.includes(:mail_layout). where(:klass => mail.class.to_s, :action => mail.action_name) end |
Instance Attribute Details
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
14 15 16 |
# File 'lib/mailtime/active_record/models/mail_template.rb', line 14 def templates @templates end |
Instance Method Details
#html ⇒ Object
21 22 23 24 25 |
# File 'lib/mailtime/active_record/models/mail_template.rb', line 21 def html _template = @templates.where(:format => 'html').first return _template if _template Mailtime.configuration.fallback ? nil : NullHTMLTemplate.new(@mail) end |
#text ⇒ Object Also known as: txt
27 28 29 30 31 |
# File 'lib/mailtime/active_record/models/mail_template.rb', line 27 def text _template = @templates.where(:format => 'text').first return _template if _template Mailtime.configuration.fallback ? nil : NullTextTemplate.new(@mail) end |