Sha256: b723919acaf619348a1588fc97d4bb8562c8247c3df05ee53e9bb1d1144310ba

Contents?: true

Size: 1001 Bytes

Versions: 4

Compression:

Stored size: 1001 Bytes

Contents

module Gossiper
  class EmailConfig
    attr_reader :notification, :user

    def initialize(notification)
      @notification = notification
      @user = notification.user rescue nil
    end

    def from
      config.default_from
    end

    def reply_to
      config.default_reply_to.presence || config.default_from
    end

    def to
      if user.respond_to?(:name)
        ["#{user.name} <#{user.email}>"]
      else
        [user.email]
      end
    end

    def bcc
      config.default_bcc
    end

    def cc
      config.default_cc
    end

    def template_name
      "#{notification.kind}_notification"
    end

    def template_path
      'notifications'
    end

    def subject
      I18n.t("gossiper.notifications.#{notification.kind}.subject", subject_variables)
    end

    def attachments
      {}
    end

    def instance_variables
      {}
    end

    def subject_variables
      {}
    end

    private
      def config
        Gossiper.configuration
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gossiper-0.3.8 lib/gossiper/email_config.rb
gossiper-0.3.7 lib/gossiper/email_config.rb
gossiper-0.3.6 lib/gossiper/email_config.rb
gossiper-0.3.5 lib/gossiper/email_config.rb