Class: Pubnub::Subscription

Inherits:
Object show all
Defined in:
lib/pubnub/subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Subscription

Returns a new instance of Subscription.



5
6
7
8
# File 'lib/pubnub/subscription.rb', line 5

def initialize(options)
  @channel = options[:channel]
  @callback = options[:callback]
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



3
4
5
# File 'lib/pubnub/subscription.rb', line 3

def callback
  @callback
end

#channelObject

Returns the value of attribute channel.



3
4
5
# File 'lib/pubnub/subscription.rb', line 3

def channel
  @channel
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/pubnub/subscription.rb', line 16

def ==(other)
  (@channel == other.get_channel && @callback == other.callback && @error_callback == other.error_callback)
end

#fire_callback_for(envelope) ⇒ Object



10
11
12
13
14
# File 'lib/pubnub/subscription.rb', line 10

def fire_callback_for(envelope)
  $log.debug "CALLING SUBSCRIPTION CALLBACK FOR CHANNEL #{@channel}" if envelope.channel == @channel
  @callback.call envelope if envelope.channel == @channel
  $log.debug "AFTER CALLING SUBSCRIPTION CALLBACK FOR CHANNEL #{@channel}"
end

#get_channelObject



20
21
22
# File 'lib/pubnub/subscription.rb', line 20

def get_channel
  @channel
end