Class: PYAPNS::ClientConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/pyapns.rb

Overview

PYAPNS::ClientConfiguration A middleware class to make PYAPNS::Client easy to use in web contexts

Automates configuration of the client in Rack environments using a simple confiuration middleware. To use PYAPNS::Client in Rack environments with the least code possible use PYAPNS::ClientConfiguration (no, really, in some cases, that’s all you need!) middleware with an optional hash specifying the client variables. Options are as follows:

use PYAPNS::ClientConfiguration(
     :host => 'http://localhost/' 
     :port => 7077,
     :initial => [{
         :app_id => 'myapp',
         :cert => '/home/myuser/apps/myapp/cert.pem',
         :env => 'sandbox',
         :timeout => 15
}])

Where the configuration variables are defined:

:host     String      the host where the server can be found
:port     Number      the port to which the client should connect
:initial  Array       OPTIONAL - an array of INITIAL hashes

INITIAL HASHES:

:app_id   String      the id used to send messages with this certification
                      can be a totally arbitrary value
:cert     String      a path to the certification or the certification file
                      as a string
:env      String      the environment to connect to apple with, always
                      either 'sandbox' or 'production'
:timoeut  Number      The timeout for the server to use when connecting
                      to the apple servers

Instance Method Summary collapse

Constructor Details

#initialize(app, hash = {}) ⇒ ClientConfiguration

Returns a new instance of ClientConfiguration.



266
267
268
269
# File 'lib/pyapns.rb', line 266

def initialize(app, hash={})
  @app = app
  PYAPNS::Client.configure(hash)
end

Instance Method Details

#call(env) ⇒ Object



271
272
273
# File 'lib/pyapns.rb', line 271

def call(env)
  @app.call(env)
end