Sha256: 35b7d5785d8257bcb26343765bcbbc55bbbcf7d11c2eafb7c0f750c50c3fc370

Contents?: true

Size: 491 Bytes

Versions: 9

Compression:

Stored size: 491 Bytes

Contents

module Effective
  class LiquidMailer < ::ActionMailer::Base
    def mail(headers = {}, &block)
      # this be dangerous and requires ruby 2.0+
      mail_method = caller_locations(1, 1)[0].label
      options = EffectiveEmailTemplates.get(mail_method).mail_options

      if options[:subject].present?
        options[:subject] = Liquid::Template.parse(options[:subject]).render(@to_liquid) rescue options[:subject]
      end

      super(headers.merge(options), &block)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
effective_email_templates-0.4.6 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.5 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.4 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.3 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.2 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.1 lib/effective/liquid_mailer.rb
effective_email_templates-0.4.0 lib/effective/liquid_mailer.rb
effective_email_templates-0.3.5 lib/effective/liquid_mailer.rb
effective_email_templates-0.3.4 lib/effective/liquid_mailer.rb