class StableRedisPagination::Paginator::Orderer

Public Instance Methods

ordered_ids() click to toggle source
# File lib/stable_redis_pagination/paginator.rb, line 30
def ordered_ids
  StableRedisPagination.redis.send("#{redis_command_prefix}range", index, start, start + count - 1).map(&:to_i)
end

Private Instance Methods

redis_command_prefix() click to toggle source
# File lib/stable_redis_pagination/paginator.rb, line 45
def redis_command_prefix
  redis_command_prefix = order.to_s.downcase != 'desc' ? 'z' : 'zrev'
end
start() click to toggle source
# File lib/stable_redis_pagination/paginator.rb, line 36
def start
  if after_id.nil?
    0
  else
    rank = StableRedisPagination.redis.send("#{redis_command_prefix}rank", index, after_id)
    rank.nil? ? 0 : rank + 1
  end
end