Class: Pushr::Daemon::Apns2Support::Push

Inherits:
Object
  • Object
show all
Defined in:
lib/pushr/daemon/apns2_support/push.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http2_request) ⇒ Push

Returns a new instance of Push.



7
8
9
10
11
12
13
14
# File 'lib/pushr/daemon/apns2_support/push.rb', line 7

def initialize(http2_request)
  @http2_request = http2_request
  @headers = {}
  @data = ''
  @events = {}

  listen_for_http2_events
end

Instance Attribute Details

#http2_requestObject (readonly)

Returns the value of attribute http2_request.



5
6
7
# File 'lib/pushr/daemon/apns2_support/push.rb', line 5

def http2_request
  @http2_request
end

Instance Method Details

#emit(event, arg) ⇒ Object



23
24
25
26
# File 'lib/pushr/daemon/apns2_support/push.rb', line 23

def emit(event, arg)
  return unless @events[event]
  @events[event].each { |b| b.call(arg) }
end

#on(event, &block) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/pushr/daemon/apns2_support/push.rb', line 16

def on(event, &block)
  raise ArgumentError, 'on event must provide a block' unless block_given?

  @events[event] ||= []
  @events[event] << block
end