Class: NotificationDecorator
- Inherits:
-
Object
- Object
- NotificationDecorator
- Defined in:
- lib/bat_notifications.rb
Overview
decorator class that serves as super class for concrete decorators. includes functions that is common to all concrete decorators
Direct Known Subclasses
BasicNotification, BookingNotification, InboxNotification, ReviewNotification, UserBookingNotification, UserReviewNotification
Instance Method Summary collapse
- #async_email ⇒ Object
- #get_action ⇒ Object
- #get_content ⇒ Object
- #get_receiver ⇒ Object
- #get_receiver_full_name ⇒ Object
- #get_sender ⇒ Object
- #get_sender_full_name ⇒ Object
-
#initialize(notification) ⇒ NotificationDecorator
constructor
initialize our constructor.
- #message ⇒ Object
-
#send_email ⇒ Object
send email using Pony.
- #send_notification_to_receiver ⇒ Object
- #send_notification_to_sender ⇒ Object
Constructor Details
#initialize(notification) ⇒ NotificationDecorator
initialize our constructor
41 42 43 44 45 46 47 |
# File 'lib/bat_notifications.rb', line 41 def initialize(notification) @notification = notification @action = "" @sender = get_sender @receiver = get_receiver @content = get_content end |
Instance Method Details
#async_email ⇒ Object
99 100 101 102 103 |
# File 'lib/bat_notifications.rb', line 99 def async_email @mail_status = Async do self.send_email end end |
#get_action ⇒ Object
61 62 63 |
# File 'lib/bat_notifications.rb', line 61 def get_action return @action end |
#get_content ⇒ Object
49 50 51 |
# File 'lib/bat_notifications.rb', line 49 def get_content return @notification.get_content end |
#get_receiver ⇒ Object
57 58 59 |
# File 'lib/bat_notifications.rb', line 57 def get_receiver return @notification.get_receiver end |
#get_receiver_full_name ⇒ Object
109 110 111 |
# File 'lib/bat_notifications.rb', line 109 def get_receiver_full_name return "#{@receiver['firstname']} #{@receiver['lastname']}" end |
#get_sender ⇒ Object
53 54 55 |
# File 'lib/bat_notifications.rb', line 53 def get_sender return @notification.get_sender end |
#get_sender_full_name ⇒ Object
105 106 107 |
# File 'lib/bat_notifications.rb', line 105 def get_sender_full_name return "#{@sender['firstname']} #{@sender['lastname']}" end |
#message ⇒ Object
66 67 68 |
# File 'lib/bat_notifications.rb', line 66 def return "You have a new #{@action} from #{get_sender}. Check out the details" end |
#send_email ⇒ Object
send email using Pony
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/bat_notifications.rb', line 71 def send_email begin Pony.mail( :to => @receiver_email, :from => @sender_email, :subject => @subject, :html_body => self., :body => self., :via => :smtp, :via_options => { :address => 'smtp.gmail.com', :port => '587', :enable_starttls_auto => true, :user_name => '[email protected]', :password => 'b00katut0r@123!', :authentication => :plain, :domain => "localhost.localdomain" } ) #return message-sent == true rescue Exception => e puts e. puts e.backtrace.inspect end end |
#send_notification_to_receiver ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/bat_notifications.rb', line 122 def send_notification_to_receiver @sender_email = "[email protected]" @receiver_email = self.get_receiver["email"] async_email return @mail_status.wait.content_type.length end |
#send_notification_to_sender ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/bat_notifications.rb', line 113 def send_notification_to_sender @sender_email = "[email protected]" @receiver_email = self.get_sender["email"] async_email return @mail_status.wait.content_type.length end |