Class: Redis::EnumerableObject
- Inherits:
-
BaseObject
- Object
- BaseObject
- Redis::EnumerableObject
- Includes:
- Enumerable
- Defined in:
- lib/redis/enumerable_object.rb
Overview
Class representing a Redis enumerable type (list, set, sorted set, or hash).
Instance Attribute Summary
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#as_json ⇒ Object
ActiveSupport’s core extension ‘Enumerable#as_json` implementation is incompatible with ours.
-
#each(&block) ⇒ Object
Iterate through each member.
- #sort(options = {}) ⇒ Object
Methods inherited from BaseObject
#allow_expiration, #initialize, #redis, #set_expiration, #to_hash, #to_json
Methods included from Helpers::CoreCommands
#delete, #exists?, #expire, #expireat, #marshal, #move, #persist, #rename, #renamenx, #serializer, #ttl, #type, #unmarshal
Constructor Details
This class inherits a constructor from Redis::BaseObject
Instance Method Details
#as_json ⇒ Object
ActiveSupport’s core extension ‘Enumerable#as_json` implementation is incompatible with ours.
24 25 26 |
# File 'lib/redis/enumerable_object.rb', line 24 def as_json(*) to_hash end |
#each(&block) ⇒ Object
Iterate through each member. Redis::Objects mixes in Enumerable, so you can also use familiar methods like collect
, detect
, and so forth.
12 13 14 |
# File 'lib/redis/enumerable_object.rb', line 12 def each(&block) value.each(&block) end |
#sort(options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/redis/enumerable_object.rb', line 16 def sort(={}) return super() if block_given? [:order] = "asc alpha" if .keys.count == 0 # compat with Ruby val = redis.sort(key, **) val.is_a?(Array) ? val.map{|v| unmarshal(v)} : val end |