Class: Pushr::Daemon::Apns2Support::Push
- Inherits:
-
Object
- Object
- Pushr::Daemon::Apns2Support::Push
- Defined in:
- lib/pushr/daemon/apns2_support/push.rb
Instance Attribute Summary collapse
-
#http2_request ⇒ Object
readonly
Returns the value of attribute http2_request.
Instance Method Summary collapse
- #emit(event, arg) ⇒ Object
-
#initialize(http2_request) ⇒ Push
constructor
A new instance of Push.
- #on(event, &block) ⇒ Object
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_request ⇒ Object (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
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 |