lib/leaderboard_factory.rb
# Method what actually does the defining.
Method what actually does the defining.
Method what actually does the defining .
def define_methods board, type = :instance, prefix = ''
      singluar_object, *remainder_of_name = board.split("_")
      singluar_object = singluar_object.singularize
      accessor_method_name = ([singluar_object] + remainder_of_name).join("_")
      class_eval <<-METHODS, __FILE__, __LINE__
        def #{prefix}#{board}
          return @#{board} if @#{board}
          options               = leaderboard_specs[:#{type}]['#{board}'][:options]
          redis_options         = leaderboard_specs[:#{type}]['#{board}'][:redis_options]
          redis_key             = leaderboard_specs[:#{type}]['#{board}'][:key]
          redis_options.merge!({
            redis_connection: LeaderboardFactory.redis
          })
          @#{board} = Leaderboard.new( leaderboards.board_name('#{board}', redis_key),
                                       Leaderboard::DEFAULT_OPTIONS.merge(options),
                                       redis_options )
        end
        def #{prefix}rank_#{accessor_method_name} object, rank, member_data = nil
          #{board}.rank_member object, rank, member_data
        end
      METHODS
    end
def define_methods board , type = :instance , prefix = '' singluar_object , * remainder_of_name = board . split ( "_" ) singluar_object = singluar_object . singularize accessor_method_name = ( [ singluar_object ] + remainder_of_name ) . join ( "_" ) class_eval <<-METHODS , __FILE__ , __LINE__ 
        def  #{ prefix } #{ board } 
          return @ #{ board }  if @ #{ board } 
          options               = leaderboard_specs[: #{ type } ][' #{ board } '][:options]
          redis_options         = leaderboard_specs[: #{ type } ][' #{ board } '][:redis_options]
          redis_key             = leaderboard_specs[: #{ type } ][' #{ board } '][:key]

          redis_options.merge!({
            redis_connection: LeaderboardFactory.redis
          })

          @ #{ board }  = Leaderboard.new( leaderboards.board_name(' #{ board } ', redis_key),
                                       Leaderboard::DEFAULT_OPTIONS.merge(options),
                                       redis_options )
        end

        def  #{ prefix } rank_ #{ accessor_method_name }  object, rank, member_data = nil
           #{ board } .rank_member object, rank, member_data
        end
       METHODS end
Method what actually does the defining.
Method what actually does the defining .
board
type
prefix