Class: Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/extensions/mail.rb

Direct Known Subclasses

GeneralMail, GeneralMailNoLink

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Mail

Returns a new instance of Mail.



4
5
6
7
# File 'lib/sinatra/extensions/mail.rb', line 4

def initialize(args)
  @receivers = args[:to]
  @sender = args[:from]
end

Instance Method Details

#fromObject



27
28
29
# File 'lib/sinatra/extensions/mail.rb', line 27

def from 
  @sender ||= "[email protected]"
end

#sendObject



31
32
33
# File 'lib/sinatra/extensions/mail.rb', line 31

def send
  MailSender.perform_async(self)
end

#subjectObject

Raises:

  • (Exception)


13
14
15
# File 'lib/sinatra/extensions/mail.rb', line 13

def subject
  raise Exception, "You have to override 'subject' method in #{self.class}"
end

#templateObject

Raises:

  • (Exception)


9
10
11
# File 'lib/sinatra/extensions/mail.rb', line 9

def template
  raise Exception, "You have to override 'template' method in #{self.class}"
end

#toObject



21
22
23
24
25
# File 'lib/sinatra/extensions/mail.rb', line 21

def to
  _receivers = {}
  @receivers.each { |user| _receivers[user.hxt_id] = "User" }
  _receivers
end

#valuesObject

Raises:

  • (Exception)


17
18
19
# File 'lib/sinatra/extensions/mail.rb', line 17

def values
  raise Exception, "You have to override 'values' method in #{self.class}"
end