Class: Rapns::Config
- Inherits:
-
Struct
- Object
- Struct
- Rapns::Config
- Defined in:
- lib/rapns/config.rb
Overview
A class to hold Rapns configuration settings and callbacks.
Instance Attribute Summary collapse
-
#airbrake_notify ⇒ Object
Returns the value of attribute airbrake_notify.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#check_for_errors ⇒ Object
Returns the value of attribute check_for_errors.
-
#feedback_callback ⇒ Object
Returns the value of attribute feedback_callback.
-
#feedback_poll ⇒ Object
Returns the value of attribute feedback_poll.
-
#foreground ⇒ Object
Returns the value of attribute foreground.
-
#pid_file ⇒ Object
Returns the value of attribute pid_file.
-
#push_poll ⇒ Object
Returns the value of attribute push_poll.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Initialize the Config with default values.
-
#on_feedback(&block) ⇒ Object
Define a block that will be executed with a Rapns::Feedback instance when feedback has been received from the push notification servers that a notification has failed to be delivered.
Constructor Details
#initialize ⇒ Config
Initialize the Config with default values
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rapns/config.rb', line 22 def initialize super # defaults: self.foreground = false self.push_poll = 2 self.feedback_poll = 60 self.airbrake_notify = true self.check_for_errors = true self.batch_size = 5000 end |
Instance Attribute Details
#airbrake_notify ⇒ Object
Returns the value of attribute airbrake_notify
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def airbrake_notify @airbrake_notify end |
#batch_size ⇒ Object
Returns the value of attribute batch_size
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def batch_size @batch_size end |
#check_for_errors ⇒ Object
Returns the value of attribute check_for_errors
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def check_for_errors @check_for_errors end |
#feedback_callback ⇒ Object
Returns the value of attribute feedback_callback.
19 20 21 |
# File 'lib/rapns/config.rb', line 19 def feedback_callback @feedback_callback end |
#feedback_poll ⇒ Object
Returns the value of attribute feedback_poll
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def feedback_poll @feedback_poll end |
#foreground ⇒ Object
Returns the value of attribute foreground
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def foreground @foreground end |
#pid_file ⇒ Object
Returns the value of attribute pid_file
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def pid_file @pid_file end |
#push_poll ⇒ Object
Returns the value of attribute push_poll
17 18 19 |
# File 'lib/rapns/config.rb', line 17 def push_poll @push_poll end |
Instance Method Details
#on_feedback(&block) ⇒ Object
Define a block that will be executed with a Rapns::Feedback instance when feedback has been received from the push notification servers that a notification has failed to be delivered. Further notifications should not be sent to this device token.
Example usage (in config/initializers/rapns.rb):
Rapns.configure do |config|
config.on_feedback do |feedback|
device = Device.find_by_device_token feedback.device_token
if device
device.active = false
device.save
end
end
end
Where ‘Device` is a model specific to your Rails app that has a `device_token` field.
51 52 53 |
# File 'lib/rapns/config.rb', line 51 def on_feedback(&block) self.feedback_callback = block end |