Sha256: 149fb877701322234daad78c4b963697cc9662bad42c20851e25c0eb1cc672d0
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
require 'faraday' module GCMMiddleware class CanonicalId < Faraday::Middleware def call(env) save_ids(env.body) @app.call(env).on_complete do |env| inject_original_ids(env.body) if has_registration_ids && env.body end end private attr_reader :registration_ids def inject_original_ids(body) body['results'].each_with_index do |result, i| result['original_id'] = registration_ids[i] end end def save_ids(body) @registration_ids = body.fetch('registration_ids', []) if body end def has_registration_ids registration_ids && registration_ids.any? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gcm_middleware-0.0.2 | lib/gcm_middleware/canonical_id.rb |