Module: APN::Connection::Base

Included in:
Feedback, Sender
Defined in:
lib/apn/connection/base.rb

Overview

APN::Connection::Base takes care of all the boring certificate loading, socket creating, and logging responsibilities so APN::Sender and APN::Feedback and focus on their respective specialties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/apn/connection/base.rb', line 10

def logger
  @logger
end

#optsObject

Returns the value of attribute opts.



10
11
12
# File 'lib/apn/connection/base.rb', line 10

def opts
  @opts
end

Instance Method Details

#initialize(opts = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/apn/connection/base.rb', line 12

def initialize(opts = {})
  @opts = opts

  setup_logger
  log(:info, "APN::Sender initializing. Establishing connections first...") if @opts[:verbose]
  setup_paths

  super( APN::QUEUE_NAME ) if self.class.ancestors.include?(Resque::Worker)
end

#resque_logObject

Log message to any logger provided by the user (e.g. the Rails logger). Accepts log_level, message, since that seems to make the most sense, and just message, to be compatible with Resque’s log method and to enable sending verbose and very_verbose worker messages to e.g. the rails logger.#

Perhaps a method definition of +message, level would make more sense, but that’s also the complete opposite of what anyone comming from rails would expect.



46
# File 'lib/apn/connection/base.rb', line 46

alias_method(:resque_log, :log)

#socketObject

Lazy-connect the socket once we try to access it in some way



23
24
25
26
# File 'lib/apn/connection/base.rb', line 23

def socket
  setup_connection unless @socket
  return @socket
end