Class: Qcourses::Postman

Inherits:
Object
  • Object
show all
Defined in:
lib/qcourses/models/postman.rb

Constant Summary collapse

FROM_ADDRESS =
"[email protected]"
NOTIFICATION_ADDRESS =
"[email protected]"
@@allow_delivery_failure =
false

Class Method Summary collapse

Class Method Details

.allow_delivery_failureObject



27
28
29
# File 'lib/qcourses/models/postman.rb', line 27

def self.allow_delivery_failure
  @@allow_delivery_failure = true
end

.deliver(options) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/qcourses/models/postman.rb', line 42

def self.deliver(options)
  begin
  Pony.mail(options)
  rescue Exception => e
    raise e unless @@allow_delivery_failure
  end
end

.deliver_registration_confirmation(addressee, registration_confirmation) ⇒ Object



37
38
39
40
41
# File 'lib/qcourses/models/postman.rb', line 37

def self.deliver_registration_confirmation(addressee, registration_confirmation)
  deliver(from: FROM_ADDRESS,
            to: addressee, 
            subject: "Thank you for your registration for #{registration_confirmation.event_name}")
end

.deliver_registration_notification(registration_confirmation) ⇒ Object



33
34
35
36
# File 'lib/qcourses/models/postman.rb', line 33

def self.deliver_registration_notification(registration_confirmation)
  deliver(from: FROM_ADDRESS, to: NOTIFICATION_ADDRESS,
           subject: "Course Registration for #{registration_confirmation.event_name}")
end

.dont_allow_delivery_failureObject



30
31
32
# File 'lib/qcourses/models/postman.rb', line 30

def self.dont_allow_delivery_failure
  @@allow_delivery_failure = false
end