Class: ActivityMailer Private

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/activity_mailer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The mailer for activities. This is meant to be called by the activities framework alone.

Direct Known Subclasses

ConsolidatedOpeningReminderMailer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#layoutObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


8
9
10
# File 'app/mailers/activity_mailer.rb', line 8

def layout
  @layout
end

Instance Method Details

#email(recipient:, notification:, view_path:, layout_path: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Emails a recipient, informing him of an activity.

Parameters:

  • recipient (User)

    The recipient of the email.

  • notification (Course::Notification|UserNotification)

    The notification to be made available to the view, accessible using [email protected]+.

  • view_path (String)

    The path to the view which should be rendered.

  • layout_path (String)

    The filename in app/views/layouts which should be rendered. If not specified, the 'mailer' layout specified in ApplicationMailer is used.


20
21
22
23
24
25
26
27
28
29
# File 'app/mailers/activity_mailer.rb', line 20

def email(recipient:, notification:, view_path:, layout_path: nil)
  ActsAsTenant.without_tenant do
    @recipient = recipient
    @notification = notification
    @object = notification.activity.object
    @layout = layout_path
    return unless @object # Object could be deleted already
    mail(to: recipient.email, template: view_path)
  end
end

#mail(options) ⇒ Object (protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds support for the +template+ option, which specifies an absolute path.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :template (String) — default: nil

    The absolute template path to render.

See Also:

  • ActivityMailer#{ActionMailer#{ActionMailer::Base#{ActionMailer::Base#mail}

37
38
39
40
41
42
43
44
45
# File 'app/mailers/activity_mailer.rb', line 37

def mail(options)
  template = options.delete(:template)
  if template
    options[:template_path] = File.dirname(template)
    options[:template_name] = File.basename(template)
  end

  super
end