Module: Blacklight::Document::Email
- Defined in:
- app/models/concerns/blacklight/document/email.rb
Overview
This module provides the body of an email export based on the document's semantic values
Instance Method Summary collapse
-
#to_email_text(config = nil) ⇒ Object
Return a text string that will be the body of the email.
Instance Method Details
#to_email_text(config = nil) ⇒ Object
Return a text string that will be the body of the email
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/concerns/blacklight/document/email.rb', line 5 def to_email_text(config = nil) body = [] if config body = config.email_fields.map do |name, field| values = [self[name]].flatten "#{field.label} #{values.join(' ')}" if self[name].present? end end # Use to_semantic_values for backwards compatibility if body.empty? semantics = to_semantic_values body << I18n.t('blacklight.email.text.title', value: semantics[:title].join(" ")) if semantics[:title].present? body << I18n.t('blacklight.email.text.author', value: semantics[:author].join(" ")) if semantics[:author].present? body << I18n.t('blacklight.email.text.format', value: semantics[:format].join(" ")) if semantics[:format].present? body << I18n.t('blacklight.email.text.language', value: semantics[:language].join(" ")) if semantics[:language].present? end return body.join("\n") unless body.empty? end |