lib/leaderboard_factory.rb
def collection_leaderboard board, options = {}, redis_options = {}
      self.leaderboard_specs[:collection][board] = {
        options: options,
        redis_options: redis_options
      }

      define_methods board, :collection, 'self.'
    end
# As +leaderboard+, but on the class rather than the instance.
# it does not take a +scope_key+ parameter, but all other functionality is the same.
#
# @param board [String] the name of the leaderboard
# @param scope_key [String/Symbol] the name of an attribute on the instance that will scope the leaderboard.
# @param options [Hash] optional; these are passed along to the leaderboard object
# @param redis_options [Hash] optional; these are also passed along to the leaderboard object
#
# Example
#
#    class Player < ActiveRecord::Base
#      include LeaderboardFactory
#      collection_leaderboard 'strength_of_schedule'
#    end
#
#    Player.strength_of_schedule # => the leaderboard object
#    Player.rank_strength_of_schedule 232, 66.3, { player_name: 'Bob' } # => ["OK", true]
As +leaderboard+, but on the class rather than the instance.
it does not take a +scope_key+ parameter, but all other functionality is the same.
As + leaderboard + but on the class rather than the instance . it does not take a + scope_key + parameter but all other functionality is the same .
def collection_leaderboard board, options = {}, redis_options = {}
      self.leaderboard_specs[:collection][board] = {
        options: options,
        redis_options: redis_options
      }
      define_methods board, :collection, 'self.'
    end
def collection_leaderboard board , options = { } , redis_options = { } self . leaderboard_specs [ :collection ] [ board ] = { options : options , redis_options : redis_options } define_methods board , :collection , 'self.' end
As +leaderboard+, but on the class rather than the instance.
As + leaderboard + but on the class rather than the instance .
board
the name of the leaderboard
the name of the leaderboard
options
optional; these are passed along to the leaderboard object
optional ; these are passed along to the leaderboard object
redis_options
optional; these are also passed along to the leaderboard object Example class Player < ActiveRecord::Base include LeaderboardFactory collection_leaderboard 'strength_of_schedule' end Player.strength_of_schedule # => the leaderboard object Player.rank_strength_of_schedule 232, 66.3, { player_name: 'Bob' } # => ["OK", true]
optional ; these are also passed along to the leaderboard object Example class Player < ActiveRecord :: Base include LeaderboardFactory collection_leaderboard ' strength_of_schedule ' end Player . strength_of_schedule # = > the leaderboard object Player . rank_strength_of_schedule 232 66 . 3 { player_name : ' Bob ' } # = > [ " OK " true ]
scope_key
the name of an attribute on the instance that will scope the leaderboard.
the name of an attribute on the instance that will scope the leaderboard .