Sha256: aaa7ba3f28949e85e710958bba57ad49d85750aa1b00abee337b8424d2532632

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

# This module provides the body of an email export based on the document's semantic values
module Blacklight::Document::Sms
  # Return a text string that will be the body of the email
  def to_sms_text(config = nil)
    body = []

    if config
      body = config.sms_fields.map do |name, field|
        values = [self[name]].flatten
        "#{field.label} #{values.first}" if self[name].present?
      end
    end

    # Use to_semantic_values for backwards compatibility
    if body.empty?
      semantics = to_semantic_values
      body << I18n.t('blacklight.sms.text.title', value: semantics[:title].first) if semantics[:title].present?
      body << I18n.t('blacklight.sms.text.author', value: semantics[:author].first) if semantics[:author].present?
    end

    return body.join unless body.empty?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight-8.0.0.beta4 app/models/concerns/blacklight/document/sms.rb
blacklight-8.0.0.beta3 app/models/concerns/blacklight/document/sms.rb
blacklight-8.0.0.beta2 app/models/concerns/blacklight/document/sms.rb
blacklight-8.0.0.beta1 app/models/concerns/blacklight/document/sms.rb