Sha256: 5d9eac8f0cabf9b3f4163598d0ba56245d7fc0fcc67b7949652b58b60b4233f5

Contents?: true

Size: 441 Bytes

Versions: 2

Compression:

Stored size: 441 Bytes

Contents

module ApnServer
  module Payload
    PayloadInvalid = Class.new(RuntimeError)

    def create_payload(payload)
      case payload
        when String then { :aps => { :alert =>  payload } }
        when Hash then create_payload_from_hash(payload)
      end
    end

    def create_payload_from_hash(payload)
      custom = payload.delete(:custom)
      aps = {:aps => payload }
      aps.merge!(custom) if custom
      aps
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apnserver-0.2.2 lib/apnserver/payload.rb
apnserver-0.2.1 lib/apnserver/payload.rb