Class: APN::Feedback
- Inherits:
-
Object
- Object
- APN::Feedback
- Defined in:
- lib/apn/feedback.rb
Overview
When supplied with the certificate path and the desired environment, connects to the APN Feedback Service and returns any response as an array of APN::FeedbackItem elements.
See README for usage and details.
Instance Method Summary collapse
-
#data(force = nil) ⇒ Object
Returns array of APN::FeedbackItem elements read from Apple.
-
#initialize(options = {}) ⇒ Feedback
constructor
A new instance of Feedback.
-
#inspect ⇒ Object
Prettify to return meaningful status information when printed.
-
#to_s ⇒ Object
Prettify to return meaningful status information when printed.
-
#tokens(force = nil) ⇒ Object
Wrapper around
datareturning just an array of token strings.
Constructor Details
#initialize(options = {}) ⇒ Feedback
Returns a new instance of Feedback.
24 25 26 |
# File 'lib/apn/feedback.rb', line 24 def initialize( = {}) @apn_host, @apn_port = [:host], [:port] end |
Instance Method Details
#data(force = nil) ⇒ Object
Returns array of APN::FeedbackItem elements read from Apple. Connects to Apple once and caches the data, continues to returns cached data unless called with data(true), which clears the existing feedback array. Note that once you force resetting the cache you loose all previous feedback, so be sure you’ve already processed it.
32 33 34 35 |
# File 'lib/apn/feedback.rb', line 32 def data(force = nil) @feedback = nil if force @feedback ||= receive end |
#inspect ⇒ Object
Prettify to return meaningful status information when printed. Can’t add these directly to connection/base, because Resque depends on decoding to_s
43 44 45 |
# File 'lib/apn/feedback.rb', line 43 def inspect "#<#{self.class.name}: #{to_s}>" end |
#to_s ⇒ Object
Prettify to return meaningful status information when printed. Can’t add these directly to connection/base, because Resque depends on decoding to_s
48 49 50 |
# File 'lib/apn/feedback.rb', line 48 def to_s "#{@client ? 'Connected' : 'Connection not currently established'} to #{host} on #{port}" end |
#tokens(force = nil) ⇒ Object
Wrapper around data returning just an array of token strings.
38 39 40 |
# File 'lib/apn/feedback.rb', line 38 def tokens(force = nil) data(force).map(&:token) end |