class Redis::EnumerableObject

Class representing a Redis enumerable type (list, set, sorted set, or hash).

Public Instance Methods

as_json(*) click to toggle source

ActiveSupport’s core extension ‘Enumerable#as_json` implementation is incompatible with ours.

# File lib/redis/enumerable_object.rb, line 24
def as_json(*)
  to_hash
end
each(&block) click to toggle source

Iterate through each member. Redis::Objects mixes in Enumerable, so you can also use familiar methods like collect, detect, and so forth.

# File lib/redis/enumerable_object.rb, line 12
def each(&block)
  value.each(&block)
end
sort(options={}) click to toggle source
Calls superclass method
# File lib/redis/enumerable_object.rb, line 16
def sort(options={})
  return super() if block_given?
  options[:order] = "asc alpha" if options.keys.count == 0  # compat with Ruby
  val = redis.sort(key, **options)
  val.is_a?(Array) ? val.map{|v| unmarshal(v)} : val
end