Sha256: d8b10424d1619782ff1f1b46e540fa5b266a4dd2792e8e84d0e389842631f0f1
Contents?: true
Size: 820 Bytes
Versions: 1
Compression:
Stored size: 820 Bytes
Contents
require File.dirname(__FILE__) + '/base_object' class Redis # # Class representing a Redis enumerable type (list, set, sorted set, or hash). # class EnumerableObject < BaseObject include Enumerable # Iterate through each member. Redis::Objects mixes in Enumerable, # so you can also use familiar methods like +collect+, +detect+, and so forth. def each(&block) value.each(&block) end 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 # ActiveSupport's core extension `Enumerable#as_json` implementation is incompatible with ours. def as_json(*) to_hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis-objects-1.5.0 | lib/redis/enumerable_object.rb |