Class: Tricle::Mailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- Tricle::Mailer
- Includes:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/tricle/mailer.rb
Constant Summary collapse
- CSS =
File.read(File.join(File.dirname(__FILE__), 'templates', 'email.css')).freeze
Class Method Summary collapse
- .group(title) ⇒ Object
- .inherited(klass) ⇒ Object
- .list(klass, &block) ⇒ Object
- .metric(klass) ⇒ Object
- .send_all ⇒ Object
Instance Method Summary collapse
Class Method Details
.group(title) ⇒ Object
51 52 53 54 |
# File 'lib/tricle/mailer.rb', line 51 def group(title) self.report.add_group(title) yield if block_given? end |
.inherited(klass) ⇒ Object
46 47 48 49 |
# File 'lib/tricle/mailer.rb', line 46 def inherited(klass) klass.report = Tricle::Presenters::Report.new super(klass) end |
.list(klass, &block) ⇒ Object
60 61 62 |
# File 'lib/tricle/mailer.rb', line 60 def list(klass, &block) self.report.add_list(klass, &block) end |
.metric(klass) ⇒ Object
56 57 58 |
# File 'lib/tricle/mailer.rb', line 56 def metric(klass) self.report.add_metric(klass) end |
Instance Method Details
#email(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tricle/mailer.rb', line 30 def email( = {}) = { subject: self.subject }.merge() @report = self.report = mail() do |format| format.html { render 'templates/email' } format.text { render 'templates/email' } end premailer() end |
#premailer(message) ⇒ Object
24 25 26 27 28 |
# File 'lib/tricle/mailer.rb', line 24 def premailer() # message.text_part.body = Premailer.new(message.text_part.body.to_s, with_html_string: true).to_plain_text .html_part.body = Premailer.new(.html_part.body.to_s, css_string: CSS.dup, with_html_string: true).to_inline_css end |
#subject ⇒ Object
20 21 22 |
# File 'lib/tricle/mailer.rb', line 20 def subject "Your #{self.class.name.titleize}" end |