Class: MessageTemplate

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/message_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.localized_template(status, locale) ⇒ Object



19
20
21
# File 'app/models/message_template.rb', line 19

def self.localized_template(status, locale)
  MessageTemplate.where(status: status, locale: locale).first || MessageTemplate.where(status: status).first
end

Instance Method Details

#embed_body(options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'app/models/message_template.rb', line 11

def embed_body(options = {})
  template = Erubis::Eruby.new(body)
  context = {
    library_group: LibraryGroup.site_config
  }.merge(options)
  template.evaluate(context)
end