Sha256: cbde60942670113ef57e3639d1130dc6d311fc0d455a6e00176cb7e0322a5bf8

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

# -*- encoding : utf-8 -*-
# Only works for documents with a #to_marc right now. 
class RecordMailer < ActionMailer::Base
  
  def email_record(documents, details, from_host, url_gen_params)
    #raise ArgumentError.new("RecordMailer#email_record only works with documents with a #to_marc") unless document.respond_to?(:to_marc)
    
    recipients details[:to]
    if documents.size == 1
      subject = "Item Record: #{documents.first.to_semantic_values[:title] rescue 'N/A'}"
    else
      subject = "Item records"
    end

    @documents      = documents
    @message        = details[:message]
    @url_gen_params = url_gen_params

    mail(:to => details[:to],  :from => "no-reply@" << from_host, :subject => subject)
  end
  
  def sms_record(documents, details, from_host, url_gen_params)
    if sms_mapping[details[:carrier]]
      to = "#{details[:to]}@#{sms_mapping[details[:carrier]]}"
    end
    @documents      = documents
    @host           = from_host
    @url_gen_params = url_gen_params
    mail(:to => to, :from => "no-reply@" << from_host, :subject => "")
  end

  protected
  
  def sms_mapping
    {'virgin' => 'vmobl.com',
    'att' => 'txt.att.net',
    'verizon' => 'vtext.com',
    'nextel' => 'messaging.nextel.com',
    'sprint' => 'messaging.sprintpcs.com',
    'tmobile' => 'tmomail.net',
    'alltel' => 'message.alltel.com',
    'cricket' => 'mms.mycricket.com'}
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-3.1.2 app/models/record_mailer.rb
blacklight-3.1.1 app/models/record_mailer.rb
blacklight-3.1.0 app/models/record_mailer.rb
blacklight-3.0.0 app/models/record_mailer.rb
blacklight-3.0.0pre8 app/models/record_mailer.rb
blacklight-3.0.0pre7 app/models/record_mailer.rb