Class: Notification
- Inherits:
-
NotificationHandler::Notification
- Object
- NotificationHandler::Notification
- Notification
- Includes:
- Notifications
- Defined in:
- app/models/notification.rb
Instance Method Summary collapse
- #deliver_email ⇒ Object
- #push_notifications ⇒ Object
- #read! ⇒ Object
- #set_cta_link ⇒ Object
- #set_subject_line ⇒ Object
Instance Method Details
#deliver_email ⇒ Object
23 24 25 26 27 |
# File 'app/models/notification.rb', line 23 def deliver_email if target.settings.delivery_methods!.email! and target.settings.categories!.send("#{category}!").enabled? NotificationEmailWorker.perform_async(id) end end |
#push_notifications ⇒ Object
15 16 17 |
# File 'app/models/notification.rb', line 15 def push_notifications deliver(:email) end |
#read! ⇒ Object
19 20 21 |
# File 'app/models/notification.rb', line 19 def read! update(read: true) end |
#set_cta_link ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/notification.rb', line 29 def set_cta_link file = File.open(Rails.root.join('config/notifications/cta_links.yml')) templates = YAML.safe_load(file) self.cta_link = object.frontend_link and return unless templates.key?(type) template = ERB.new(templates[type]) self.cta_link = template.result_with_hash object: object, metadata: end |
#set_subject_line ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/notification.rb', line 40 def set_subject_line file = File.open(Rails.root.join("config/locales/#{I18n.locale}.yml")) templates = YAML.safe_load(file) self.subject_line = '' and return unless templates.dig(I18n.locale.to_s, 'notifications', 'subject_lines', type) template = ERB.new(templates.dig(I18n.locale.to_s, 'notifications', 'subject_lines', type)) self.subject_line = template.result_with_hash object: object, metadata: end |