Module: FayeTracking

Defined in:
lib/faye_tracking.rb,
lib/faye_tracking/tracker.rb,
lib/faye_tracking/version.rb,
lib/faye_tracking/faye_extension.rb,
lib/faye_tracking/redis_key_list.rb,
lib/faye_tracking/abstract_key_list.rb,
lib/faye_tracking/namespaced_key_list.rb

Defined Under Namespace

Classes: AbstractKeyList, FayeExtension, NamespacedKeyList, RedisKeyList, Tracker

Constant Summary collapse

VERSION =
"0.2.5"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/faye_tracking.rb', line 8

def logger
  @logger
end

.redisObject



47
48
49
# File 'lib/faye_tracking.rb', line 47

def redis
  @redis || raise('redis is not set')
end

Class Method Details

.configure(&block) ⇒ Object



11
12
13
# File 'lib/faye_tracking.rb', line 11

def configure(&block)
  block.call(self)
end

.faye_extensionObject



39
40
41
# File 'lib/faye_tracking.rb', line 39

def faye_extension
  @_faye_extension ||= FayeExtension.new(tracker)
end

.on_subscribe(&block) ⇒ Object



59
60
61
# File 'lib/faye_tracking.rb', line 59

def on_subscribe(&block)
  on_subscribe_callbacks << block
end

.on_subscribe_callbacksObject



55
56
57
# File 'lib/faye_tracking.rb', line 55

def on_subscribe_callbacks
  @_on_subscribe_callbacks || reset_on_subscribe_callbacks
end

.remove_from_channel(channel, client) ⇒ Object



31
32
33
# File 'lib/faye_tracking.rb', line 31

def remove_from_channel(channel, client)
  tracker.remove(channel, client)
end

.reset_on_subscribe_callbacksObject



67
68
69
# File 'lib/faye_tracking.rb', line 67

def reset_on_subscribe_callbacks
  @_on_subscribe_callbacks = []
end

.reset_storeObject



35
36
37
# File 'lib/faye_tracking.rb', line 35

def reset_store
  redis.keys('*').each {|k| redis.del k}
end

.run_on_subscribe_callbacks(*args) ⇒ Object



63
64
65
# File 'lib/faye_tracking.rb', line 63

def run_on_subscribe_callbacks(*args)
  on_subscribe_callbacks.each { |blk| blk.call(*args) }
end

.trackerObject



51
52
53
# File 'lib/faye_tracking.rb', line 51

def tracker
  @_tracker = Tracker.new(redis)
end

.user_in_any_channel?(user) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/faye_tracking.rb', line 15

def user_in_any_channel?(user)
  !tracker.channels_for_user(user).empty?
end

.user_in_channel?(user, channel) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/faye_tracking.rb', line 19

def user_in_channel?(user, channel)
  tracker.user_in_channel?(user, channel)
end

.user_with_client_id(client_id) ⇒ Object



27
28
29
# File 'lib/faye_tracking.rb', line 27

def user_with_client_id(client_id)
  tracker.user_with_client_id(client_id)
end

.users_in_channel(channel) ⇒ Object



23
24
25
# File 'lib/faye_tracking.rb', line 23

def users_in_channel(channel)
  tracker.users_in_channel(channel)
end