Sha256: 86d8db772d1576d114c5d5a5058cdb50c26cfd5317e226b3b8e5132d05d1c4b2

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
# This module provides the body of an email export based on the document's semantic values
module Blacklight::Document::Email
  # Return a text string that will be the body of the email
  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
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.39.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.38.0 app/models/concerns/blacklight/document/email.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/models/concerns/blacklight/document/email.rb
blacklight-7.37.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.36.2 app/models/concerns/blacklight/document/email.rb
blacklight-7.36.1 app/models/concerns/blacklight/document/email.rb
blacklight-7.36.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.35.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.34.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.33.1 app/models/concerns/blacklight/document/email.rb
blacklight-7.33.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.32.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.31.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.30.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.29.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.28.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.27.1 app/models/concerns/blacklight/document/email.rb
blacklight-7.27.0 app/models/concerns/blacklight/document/email.rb
blacklight-7.26.1 app/models/concerns/blacklight/document/email.rb