Class: CapGun::Mailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/cap_gun.rb

Overview

This mailer is configured with a capistrano variable called “cap_gun_email_envelope”

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_mailer_config(cap) ⇒ Object

Raises:

  • (ArgumentError)


43
44
45
# File 'lib/cap_gun.rb', line 43

def self.load_mailer_config(cap)
 raise ArgumentError, "Need at least one recipient." if !cap.exists?(:cap_gun_email_envelope) || cap[:cap_gun_email_envelope][:recipients].blank?
end

Instance Method Details

#deployment_notification(capistrano) ⇒ Object

Grab the options for emailing from capistrano (should be set in your deploy file)

Valid options:

:recipients     (required) an array or string of email address(es) that should get notifications
:from           the sender of the notification, defaults to [email protected]
:email_prefix   subject prefix, defaults to [DEPLOY]


53
54
55
56
57
58
59
60
61
62
# File 'lib/cap_gun.rb', line 53

def deployment_notification(capistrano)
  presenter = Presenter.new(capistrano)
  mail(
    :from     => presenter.from,
    :to       => presenter.recipients,
    :subject  => presenter.subject
  ) do |format|
    format.text { render :text => presenter.body }
  end
end