Class: NotificationMailers::Base

Inherits:
Object
  • Object
show all
Includes:
Diaspora::Logging
Defined in:
app/mailers/notification_mailers/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipient_id, sender_id = nil, *args) ⇒ Base

Returns a new instance of Base.


13
14
15
16
17
18
19
20
21
22
23
# File 'app/mailers/notification_mailers/base.rb', line 13

def initialize(recipient_id, sender_id=nil, *args)
  @headers = {}
  @recipient = User.find(recipient_id)
  @sender = Person.find(sender_id) if sender_id.present?

  log_mail(recipient_id, sender_id, self.class.to_s.underscore)

  with_recipient_locale do
    set_headers(*args)
  end
end

Instance Attribute Details

#recipientObject

Returns the value of attribute recipient


7
8
9
# File 'app/mailers/notification_mailers/base.rb', line 7

def recipient
  @recipient
end

#senderObject

Returns the value of attribute sender


7
8
9
# File 'app/mailers/notification_mailers/base.rb', line 7

def sender
  @sender
end

Instance Method Details

#headersObject


25
26
27
# File 'app/mailers/notification_mailers/base.rb', line 25

def headers
  default_headers.merge(@headers)
end

#name_and_address(name, email) ⇒ Object


29
30
31
32
33
# File 'app/mailers/notification_mailers/base.rb', line 29

def name_and_address(name, email)
  address = Mail::Address.new Addressable::IDNA.to_ascii(email)
  address.display_name = name
  address.format
end