Sha256: a5c03cfdb4b70213d9fb22db0fc0291aa514f69d1a4002e050c4d6a01a2ff433

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

require 'delegate'
require_relative 'connection'

module Grocer
  class PushConnection < SimpleDelegator

    PRODUCTION_GATEWAY = 'gateway.push.apple.com'
    LOCAL_GATEWAY = '127.0.0.1'
    SANDBOX_GATEWAY = 'gateway.sandbox.push.apple.com'

    def initialize(options)
      options = defaults.merge(options)
      super(Connection.new(options))
    end

    private

    def defaults
      {
        gateway: find_default_gateway,
        port: 2195
      }
    end

    def find_default_gateway
      case Grocer.env
      when 'production'
        PRODUCTION_GATEWAY
      when 'test'
        LOCAL_GATEWAY
      else
        SANDBOX_GATEWAY
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grocer-0.0.10 lib/grocer/push_connection.rb
grocer-0.0.9 lib/grocer/push_connection.rb
grocer-0.0.8 lib/grocer/push_connection.rb
grocer-0.0.7 lib/grocer/push_connection.rb