class Faye::Subscription
Public Class Methods
Source
# File lib/faye/protocol/subscription.rb, line 5 def initialize(client, channels, callback) @client = client @channels = channels @callback = callback @cancelled = false end
Public Instance Methods
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
Source
# File lib/faye/protocol/subscription.rb, line 28 def cancel return if @cancelled @client.unsubscribe(@channels, self) @cancelled = true end
Source
# File lib/faye/protocol/subscription.rb, line 24 def to_proc @to_proc ||= lambda { |*a| call(*a) } end
Source
# File lib/faye/protocol/subscription.rb, line 12 def with_channel(&callback) @with_channel = callback self end