Class: APN::Application
- Inherits:
-
Object
- Object
- APN::Application
- Includes:
- Connection
- Defined in:
- lib/apn/application.rb
Constant Summary collapse
- APPS =
{}
- OPTION_KEYS =
[:pool_size, :pool_timeout, :host, :port, :root, :full_certificate_path, :password, :certificate_name].freeze
- DELEGATE_METHODS =
[:with_connection, :connection_pool].concat(OPTION_KEYS)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from Connection
#full_certificate_path, #host, #password, #pool_size, #pool_timeout, #port, #root
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, options = {}) ⇒ Application
constructor
A new instance of Application.
- #to_h ⇒ Object
Methods included from Connection
#certificate, #certificate_name, #certificate_name=, #certificate_path, #connection_pool, #with_connection
Constructor Details
#initialize(name, options = {}) ⇒ Application
Returns a new instance of Application.
13 14 15 16 17 18 19 |
# File 'lib/apn/application.rb', line 13 def initialize(name, = {}) @name = name.to_s OPTION_KEYS.each do |key| self.send("#{key}=", .fetch(key) { APN.send("original_#{key}") } ) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/apn/application.rb', line 11 def name @name end |
Class Method Details
.register(*args) ⇒ Object
33 34 35 |
# File 'lib/apn/application.rb', line 33 def self.register(*args) new(*args).tap { |app| APPS[app.name] = app if app.certificate } end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/apn/application.rb', line 25 def == other if other.is_a?(APN::Application) to_h == other.to_h else super(other) end end |
#to_h ⇒ Object
21 22 23 |
# File 'lib/apn/application.rb', line 21 def to_h Hash[OPTION_KEYS.zip(OPTION_KEYS.map(&method(:send)))] end |