Sha256: 783d8cac464cde1060c1283f5a5c90e57fe18239d16e40f410a740b9023ae921

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

module FayeShard

  module User

    # 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.
    #
    module Faye

      #  Returns channel for a user, which is basically /ID
      #
      def faye_channel
        "/#{self.id}"
      end

      #  Pushes data to User's Faye shard
      #
      #  * <tt>data</tt>::    Data to push
      #  * <tt>ext</tt>::     Faye extensions, eg. auth_token
      #
      def push_to_faye(data, ext = {})
        FayeShards.shard(self.id).push(self.faye_channel, data, ext)
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faye_shards-0.1.1 lib/faye_shard/user/faye.rb
faye_shards-0.1.0 lib/faye_shard/user/faye.rb