Class: OneSignal::Rails::Plugin::DeliveryMethod
- Inherits:
-
Object
- Object
- OneSignal::Rails::Plugin::DeliveryMethod
- Defined in:
- lib/onesignal/rails/plugin/delivery_method.rb
Overview
Provides the ActionMailer delivery method of :onesignal. When this delivery method is used, mail sent by an ActionMailer is sent to OneSignal through an email notification. Alternatively or in addition to the standard mail funcitonality, additional OneSignal specific parameters can be specified to take advantage of OneSignal specific functionality.
Constant Summary collapse
- DEFAULTS =
{ perform_send_request: true, return_response: false, app_key: nil, app_id: nil }.freeze
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(settings = {}) ⇒ DeliveryMethod
constructor
A new instance of DeliveryMethod.
Constructor Details
#initialize(settings = {}) ⇒ DeliveryMethod
Returns a new instance of DeliveryMethod.
23 24 25 |
# File 'lib/onesignal/rails/plugin/delivery_method.rb', line 23 def initialize(settings = {}) self.settings = DEFAULTS.merge(settings) end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
21 22 23 |
# File 'lib/onesignal/rails/plugin/delivery_method.rb', line 21 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/onesignal/rails/plugin/delivery_method.rb', line 27 def deliver!(mail) validate(mail) notification = OneSignal::Notification.new({ app_id: settings[:app_id] || OneSignal::Rails::Plugin.configuration.app_id, is_ios: false }) add_from(notification, mail) add_to(notification, mail) add_subject(notification, mail) add_body(notification, mail) add_custom_notification_args(notification, mail) response = if settings[:perform_send_request] == false notification else send notification end settings[:return_response] ? response : self end |