Sha256: 51e7a47cdf2f6a78aede742fb074bc8b900cbcc9ee5969e00710295dfba775fb

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 Bytes

Contents

module APN
  module Connection

    def connection_pool
      @pool ||= ConnectionPool.new(size: (pool_size || 1), timeout: (pool_timeout || 5)) do
        APN::Client.new(host: host,
                        port: port,
                        certificate: certificate,
                        password: password)
      end
    end

    def with_connection(&block)
      connection_pool.with(&block)
    end

    # pool config
    attr_accessor :pool_size, :pool_timeout

    attr_accessor :host, :port, :root, :full_certificate_path, :password

    def certificate
      @apn_cert ||= File.read(certificate_path)
    end

    def certificate_path
      full_certificate_path || File.join(root, certificate_name)
    end

    def certificate_name
      @cert_name || "apn_production.pem"
    end

    def certificate_name=(name)
      @cert_name = name
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apn_sender-2.1.1 lib/apn/connection.rb
apn_sender-2.1.0 lib/apn/connection.rb
apn_sender-2.0.2 lib/apn/connection.rb
apn_sender-2.0.1 lib/apn/connection.rb