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, opts = {}, &block) ⇒ Object
- .metric(klass, opts = {}) ⇒ Object
- .send_all(with_period = nil) ⇒ Object
- .send_at_period ⇒ Object
- .send_today? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.group(title) ⇒ Object
52 53 54 55 |
# File 'lib/tricle/mailer.rb', line 52 def group(title) self.report.add_group(title) yield if block_given? end |
.inherited(klass) ⇒ Object
47 48 49 50 |
# File 'lib/tricle/mailer.rb', line 47 def inherited(klass) klass.report = Tricle::Presenters::Report.new super(klass) end |
.list(klass, opts = {}, &block) ⇒ Object
61 62 63 |
# File 'lib/tricle/mailer.rb', line 61 def list(klass, opts = {}, &block) self.report.add_list(klass, opts, &block) end |
.metric(klass, opts = {}) ⇒ Object
57 58 59 |
# File 'lib/tricle/mailer.rb', line 57 def metric(klass, opts = {}) self.report.add_metric(klass, opts) end |
.send_all(with_period = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/tricle/mailer.rb', line 82 def send_all(with_period = nil) klasses = Tricle::Mailer.descendants.select do |klass| !with_period || (klass.period == with_period) end send_mailers(klasses) end |
Instance Method Details
#email(options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tricle/mailer.rb', line 31 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
25 26 27 28 29 |
# File 'lib/tricle/mailer.rb', line 25 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
21 22 23 |
# File 'lib/tricle/mailer.rb', line 21 def subject "Your #{self.class.name.titleize}" end |