Class: UserRequestWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- UserRequestWorker
- Defined in:
- app/workers/user_request_worker.rb
Overview
typed: ignore frozen_string_literal: true
Instance Attribute Summary collapse
-
#cust_msg ⇒ Object
readonly
Returns the value of attribute cust_msg.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#party_size ⇒ Object
readonly
Returns the value of attribute party_size.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #body ⇒ Object
- #perform(data) ⇒ Object
- #send_email ⇒ Object
- #setup_attr(data) ⇒ Object
- #subject ⇒ Object
Methods inherited from ApplicationWorker
Instance Attribute Details
#cust_msg ⇒ Object (readonly)
Returns the value of attribute cust_msg.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def cust_msg @cust_msg end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def date @date end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def name @name end |
#party_size ⇒ Object (readonly)
Returns the value of attribute party_size.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def party_size @party_size end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def phone @phone end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def restaurant @restaurant end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'app/workers/user_request_worker.rb', line 5 def time @time end |
Instance Method Details
#body ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/workers/user_request_worker.rb', line 32 def body msg = <<MSG Restaurant: #{restaurant.name} Date: #{date} Time: #{time} Party Size: #{party_size} Name: #{name} Phone: #{phone} Message: #{cust_msg.present? ? cust_msg : '-'} MSG msg end |
#perform(data) ⇒ Object
7 8 9 10 |
# File 'app/workers/user_request_worker.rb', line 7 def perform(data) setup_attr(data) send_email end |
#send_email ⇒ Object
12 13 14 15 |
# File 'app/workers/user_request_worker.rb', line 12 def send_email mail(subject: subject, from: NO_REPLY_EMAIL, reply_to: SUPPORT_EMAIL, to: ERROR_RECIPIENT_EMAIL, bcc: SUPPORT_EMAIL_SLACK) end |
#setup_attr(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/workers/user_request_worker.rb', line 17 def setup_attr(data) @restaurant = Restaurant.find(data['restaurant_id']) @cust_msg = data['message'] @party_size = data['party_size'] @phone = data['phone'] @name = data['name'] @date = data['date'] @time = data['time'] @date = Date.parse(@date) unless @date.is_a?(Date) end |
#subject ⇒ Object
28 29 30 |
# File 'app/workers/user_request_worker.rb', line 28 def subject "Urgent Message: #{restaurant.name}" end |