class Faye::Subscription

Public Instance Methods

call(*args) click to toggle source
# File lib/faye/protocol/subscription.rb, line 17
def call(*args)
  message = args.first

  @callback.call(message['data']) if @callback
  @with_channel.call(message['channel'], message['data']) if @with_channel
end
cancel() click to toggle source
# File lib/faye/protocol/subscription.rb, line 28
def cancel
  return if @cancelled
  @client.unsubscribe(@channels, self)
  @cancelled = true
end
to_proc() click to toggle source
# File lib/faye/protocol/subscription.rb, line 24
def to_proc
  @to_proc ||= lambda { |*a| call(*a) }
end
unsubscribe() click to toggle source
# File lib/faye/protocol/subscription.rb, line 34
def unsubscribe
  cancel
end
with_channel(&callback) click to toggle source
# File lib/faye/protocol/subscription.rb, line 12
def with_channel(&callback)
  @with_channel = callback
  self
end

Public Class Methods

new(client, channels, callback) click to toggle source
# File lib/faye/protocol/subscription.rb, line 5
def initialize(client, channels, callback)
  @client    = client
  @channels  = channels
  @callback  = callback
  @cancelled = false
end