Class: RedisObj::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_obj/base.rb

Direct Known Subclasses

Hash, List, Set, SortedSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redis, key = nil) ⇒ Base

Returns a new instance of Base.



3
4
5
6
7
8
9
10
# File 'lib/redis_obj/base.rb', line 3

def initialize redis, key=nil
  unless key
    key = redis
    redis = RedisObj.redis
  end
  @key = key
  @redis = redis
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/redis_obj/base.rb', line 2

def key
  @key
end

#redisObject

Returns the value of attribute redis.



2
3
4
# File 'lib/redis_obj/base.rb', line 2

def redis
  @redis
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/redis_obj/base.rb', line 12

def == other
  self.class == other.class and self.key == other.key
end

#del_keyObject



16
17
18
# File 'lib/redis_obj/base.rb', line 16

def del_key
  redis.del(key)
end