class FakeRedis::SortedSetStore
def computed_values
def computed_values unless defined?(@computed_values) && @computed_values # Do nothing if all weights are 1, as n * 1 is n @computed_values = hashes if weights.all? {|weight| weight == 1 } # Otherwise, multiply the values in each hash by that hash's weighting @computed_values ||= hashes.each_with_index.map do |hash, index| weight = weights[index] Hash[hash.map {|k, v| [k, (v * weight)]}] end end @computed_values end