Module: APN::Connection
- Included in:
- APN
- Defined in:
- lib/apn/connection.rb
Instance Attribute Summary collapse
-
#full_certificate_path ⇒ Object
Returns the value of attribute full_certificate_path.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#pool_size ⇒ Object
pool config.
-
#pool_timeout ⇒ Object
pool config.
-
#port ⇒ Object
Returns the value of attribute port.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #certificate ⇒ Object
- #certificate_name ⇒ Object
- #certificate_name=(name) ⇒ Object
- #certificate_path ⇒ Object
- #connection_pool ⇒ Object
- #with_connection(&block) ⇒ Object
Instance Attribute Details
#full_certificate_path ⇒ Object
Returns the value of attribute full_certificate_path.
20 21 22 |
# File 'lib/apn/connection.rb', line 20 def full_certificate_path @full_certificate_path end |
#host ⇒ Object
Returns the value of attribute host.
20 21 22 |
# File 'lib/apn/connection.rb', line 20 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
20 21 22 |
# File 'lib/apn/connection.rb', line 20 def password @password end |
#pool_size ⇒ Object
pool config
18 19 20 |
# File 'lib/apn/connection.rb', line 18 def pool_size @pool_size end |
#pool_timeout ⇒ Object
pool config
18 19 20 |
# File 'lib/apn/connection.rb', line 18 def pool_timeout @pool_timeout end |
#port ⇒ Object
Returns the value of attribute port.
20 21 22 |
# File 'lib/apn/connection.rb', line 20 def port @port end |
#root ⇒ Object
Returns the value of attribute root.
20 21 22 |
# File 'lib/apn/connection.rb', line 20 def root @root end |
Instance Method Details
#certificate ⇒ Object
22 23 24 |
# File 'lib/apn/connection.rb', line 22 def certificate @apn_cert ||= File.read(certificate_path) end |
#certificate_name ⇒ Object
30 31 32 |
# File 'lib/apn/connection.rb', line 30 def certificate_name @cert_name || "apn_production.pem" end |
#certificate_name=(name) ⇒ Object
34 35 36 |
# File 'lib/apn/connection.rb', line 34 def certificate_name=(name) @cert_name = name end |
#certificate_path ⇒ Object
26 27 28 |
# File 'lib/apn/connection.rb', line 26 def certificate_path full_certificate_path || File.join(root, certificate_name) end |
#connection_pool ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/apn/connection.rb', line 4 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 |
#with_connection(&block) ⇒ Object
13 14 15 |
# File 'lib/apn/connection.rb', line 13 def with_connection(&block) connection_pool.with(&block) end |