Sha256: 10e8a66c9ebe02cecd7b28a1e3fb84a7d4a104ff99c4d632705ce95e1c6653dc

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

module Commontator
  class SubscriptionsMailer < ActionMailer::Base
    include SharedHelper
    include ThreadsHelper
  
    def comment_created(comment, recipients)
      setup_variables(comment, recipients)

      mail :to => 'Undisclosed Recipients'
           :bcc => @bcc,
           :from => @from,
           :subject => @subject
    end

    protected

    def setup_variables(comment, recipients)
      @comment = comment
      @thread = @comment.thread
      @creator = @comment.creator
      
      @commontable = @thread.commontable
      @config = @thread.config
      
      @creator_name = commontator_name(@creator)
      @comment_timestamp = @comment.timestamp
      
      @commontable_name = commontable_name(@thread)
      @commontable_id = commontable_id(@thread).to_s
      
      @commontable_url = ApplicationController.commontable_url
      
      params = Hash.new
      params[:comment] = @comment
      params[:thread] = @thread
      params[:creator] = @creator
      params[:commontable] = @commontable
      params[:config] = @config
      params[:creator_name] = @creator_name
      params[:comment_timestamp] = @comment_timestamp
      params[:commontable_name] = @commontable_name
      params[:commontable_id] = @commontable_id
      params[:commontable_url] = @commontable_url
      
      @bcc = recipients.collect{|s| commontator_email(s)}
      @from = @config.subscription_email_from_proc.call(params)
      @subject = @config.subscription_email_subject_proc.call(params)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
commontator-2.0.2 app/mailers/commontator/subscriptions_mailer.rb~
commontator-4.0.1 app/mailers/commontator/subscriptions_mailer.rb~
commontator-4.0.0 app/mailers/commontator/subscriptions_mailer.rb~