Sha256: a109b5bb39e22caf70cd692c0a2112c2bc22009a1ce775971016ef098e650829

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 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 = {})
        faye_shard.push(self.faye_channel, data, ext)
      end

      # Returns shard for this user
      #
      def faye_shard
        FayeShards.shard(self.id)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faye_shards-0.1.2 lib/faye_shard/user/faye.rb