Class: APN::Feedback
- Inherits:
-
Object
- Object
- APN::Feedback
- Includes:
- Connection::Base
- 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 Attribute Summary
Attributes included from Connection::Base
Instance Method Summary collapse
-
#data(force = nil) ⇒ Object
Returns array of APN::FeedbackItem elements read from Apple.
-
#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.
Methods included from Connection::Base
#initialize, #resque_log, #socket
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.
31 32 33 34 |
# File 'lib/apn/feedback.rb', line 31 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
42 43 44 |
# File 'lib/apn/feedback.rb', line 42 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
47 48 49 |
# File 'lib/apn/feedback.rb', line 47 def to_s "#{@socket ? 'Connected' : 'Connection not currently established'} to #{apn_host} on #{apn_port}" end |
#tokens(force = nil) ⇒ Object
Wrapper around data returning just an array of token strings.
37 38 39 |
# File 'lib/apn/feedback.rb', line 37 def tokens(force = nil) data(force).map(&:token) end |