module FayeShard::User::Faye

Module which is designed to be included to User model. It provides helper method to get token and method to push data to user’s shard.

Public Instance Methods

faye_channel() click to toggle source

Returns channel for a user, which is basically /ID

# File lib/faye_shard/user/faye.rb, line 12
def faye_channel
  "/#{self.id}"
end
faye_shard() click to toggle source

Returns shard for this user

# File lib/faye_shard/user/faye.rb, line 27
def faye_shard
  FayeShards.shard(self.id)
end
push_to_faye(data, ext = {}) click to toggle source

Pushes data to User’s Faye shard

  • data

    Data to push

  • ext

    Faye extensions, eg. auth_token

# File lib/faye_shard/user/faye.rb, line 21
def push_to_faye(data, ext = {})
  faye_shard.push(self.faye_channel, data, ext)
end