Sha256: 199177ffb5718ea5bdc7763bc029cddf5a98d57d2c8e234afcd3e390198e82c3

Contents?: true

Size: 967 Bytes

Versions: 9

Compression:

Stored size: 967 Bytes

Contents

module ActivityFeed
  module Utility
    # Feed key for a +user_id+ composed of:
    #
    # Feed: +ActivityFeed.namespace:user_id+
    # Aggregate feed: +ActivityFeed.namespace:ActivityFeed.aggregate_key:user_id+
    # 
    # @return feed key.
    def feed_key(user_id, aggregate = ActivityFeed.aggregate)
      aggregate ? 
        "#{ActivityFeed.namespace}:#{ActivityFeed.aggregate_key}:#{user_id}" :
        "#{ActivityFeed.namespace}:#{user_id}"
    end

    # Retrieve a reference to the activity feed for a given +user_id+.
    #
    # @param user_id [String] User ID.
    # @param aggregate [boolean, false] Whether to retrieve the aggregate feed for +user_id+ or not.
    #
    # @return reference to the activity feed for a given +user_id+.
    def feederboard_for(user_id, aggregate = ActivityFeed.aggregate)
      ::Leaderboard.new(feed_key(user_id, aggregate), ::Leaderboard::DEFAULT_OPTIONS, {:redis_connection => ActivityFeed.redis})
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activity_feed-3.1.0 lib/activity_feed/utility.rb
activity_feed-3.0.1 lib/activity_feed/utility.rb
activity_feed-3.0.0 lib/activity_feed/utility.rb
activity_feed-2.3.0 lib/activity_feed/utility.rb
activity_feed-2.2.2 lib/activity_feed/utility.rb
activity_feed-2.2.0 lib/activity_feed/utility.rb
activity_feed-2.1.0 lib/activity_feed/utility.rb
activity_feed-2.0.0 lib/activity_feed/utility.rb
activity_feed-2.0.0.rc1 lib/activity_feed/utility.rb