Class: Rpush::Daemon::Gcm::Results
- Inherits:
-
Object
- Object
- Rpush::Daemon::Gcm::Results
- Defined in:
- lib/rpush/daemon/gcm/delivery.rb
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#successes ⇒ Object
readonly
Returns the value of attribute successes.
Instance Method Summary collapse
-
#initialize(results_data, registration_ids) ⇒ Results
constructor
A new instance of Results.
- #process(failure_partitions = {}) ⇒ Object
Constructor Details
#initialize(results_data, registration_ids) ⇒ Results
Returns a new instance of Results.
153 154 155 156 |
# File 'lib/rpush/daemon/gcm/delivery.rb', line 153 def initialize(results_data, registration_ids) @results_data = results_data @registration_ids = registration_ids end |
Instance Attribute Details
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
151 152 153 |
# File 'lib/rpush/daemon/gcm/delivery.rb', line 151 def failures @failures end |
#successes ⇒ Object (readonly)
Returns the value of attribute successes.
151 152 153 |
# File 'lib/rpush/daemon/gcm/delivery.rb', line 151 def successes @successes end |
Instance Method Details
#process(failure_partitions = {}) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/rpush/daemon/gcm/delivery.rb', line 158 def process(failure_partitions = {}) @successes = [] @failures = Failures.new failure_partitions.each_key do |category| failures[category] = [] end @results_data.each_with_index do |result, index| entry = { registration_id: @registration_ids[index], index: index } if result['message_id'] entry[:canonical_id] = result['registration_id'] if result['registration_id'].present? successes << entry elsif result['error'] entry[:error] = result['error'] failures << entry failure_partitions.each do |category, error_states| failures[category] << entry if error_states.include?(result['error']) end end end failures.total_fail = failures.count == @registration_ids.count end |