Sha256: 65c350ca953a5ed2274c946724324475142498b5226b9965987dca912f23baa3
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module MailEngine class Base cattr_accessor :configurations, :instance_writer => false @@configurations = HashWithIndifferentAccess.new class << self # return current runtime environment config hash. # === example # # log_mail: true # sendgrid_user: "xxx@theplant.jp" # sendgrid_key: "xxx" # sendgrid_category: "development" # user_class_name: "User" # mount_at: "/admin" # def current_config MailEngine::Base.configurations[Rails.env] end # send mail template with given data. # === example # # MailEngine::Base.send_marketing_mail("newsletter", :to => 'm@theplant.jp', :values => {:users => MailEngine::USER_MODEL.last}) # def send_marketing_mail(template, *args) options = args.extract_options! options[:locale] ||= I18n.locale # ensure the :to parameter. raise "Should specify :to option" if options[:to].blank? # find the template from database. template_path = File.join("mail_engine", "mail_dispatcher", template) unless mail_template = MailEngine::MailTemplate.where(:path => template_path, :locale => options[:locale], :for_marketing => true, :partial => false).first raise "Can't find the template: #{template_path}" end options[:subject] ||= mail_template.subject I18n.with_locale(mail_template.locale) do MailEngine::MailDispatcher.send(template, options).deliver end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mail_engine-0.1.0 | lib/mail_engine/base.rb |