Module: FayeShard::User::Faye

Defined in:
lib/faye_shard/user/faye.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#faye_channelObject

Returns channel for a user, which is basically /ID



12
13
14
# File 'lib/faye_shard/user/faye.rb', line 12

def faye_channel
  "/#{self.id}"
end

#faye_shardObject

Returns shard for this user



27
28
29
# File 'lib/faye_shard/user/faye.rb', line 27

def faye_shard
  FayeShards.shard(self.id)
end

#push_to_faye(data, ext = {}) ⇒ Object

Pushes data to User’s Faye shard

* <tt>data</tt>::    Data to push
* <tt>ext</tt>::     Faye extensions, eg. auth_token


21
22
23
# File 'lib/faye_shard/user/faye.rb', line 21

def push_to_faye(data, ext = {})
  faye_shard.push(self.faye_channel, data, ext)
end