Sha256: e1e5c8020cdfd9b7b339b0764abd5adf0db99e515cdab33e774b1b0934c90640

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

module Fe
  class Notifier < ActionMailer::Base

    # call Notifier.deliver_notification
    def notification(p_recipients, p_from, template_name, template_params = {}, options = {})
      email_template = EmailTemplate.find_by_name(template_name)

      if email_template.nil?
        raise "Email Template '#{template_name}' could not be found"
      else
        set_format = options.delete(:format)
        mail({to: p_recipients,
             from: p_from,
             subject: Liquid::Template.parse(email_template.subject).render(template_params)}.merge(options)) do |format|
          case set_format.to_s
          when 'html'
            format.html { render html: Liquid::Template.parse(email_template.content).render(template_params) }
          else
            format.text { render plain: Liquid::Template.parse(email_template.content).render(template_params) }
          end
        end
        @recipients = p_recipients
        @from = p_from
        @subject = Liquid::Template.parse(email_template.subject).render(template_params)
        @body = Liquid::Template.parse(email_template.content).render(template_params)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fe-2.1.6.1 app/mailers/fe/notifier.rb
fe-2.1.6 app/mailers/fe/notifier.rb
fe-2.1.5 app/mailers/fe/notifier.rb
fe-2.1.4 app/mailers/fe/notifier.rb
fe-2.1.3 app/mailers/fe/notifier.rb
fe-2.1.2 app/mailers/fe/notifier.rb
fe-2.1.1 app/mailers/fe/notifier.rb
fe-2.0.8 app/mailers/fe/notifier.rb
fe-2.0.6 app/mailers/fe/notifier.rb
fe-2.0.5 app/mailers/fe/notifier.rb
fe-2.0.4 app/mailers/fe/notifier.rb
fe-2.0.3 app/mailers/fe/notifier.rb
fe-2.0.2 app/mailers/fe/notifier.rb
fe-2.0.1 app/mailers/fe/notifier.rb
fe-2.0.0 app/mailers/fe/notifier.rb