Class: Redis::Wrap

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/wrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Wrap

Returns a new instance of Wrap.



9
10
11
# File 'lib/redis/wrap.rb', line 9

def initialize(key)
  @key = key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(command, *arguments, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/redis/wrap.rb', line 13

def method_missing(command, *arguments, &block)
  arguments = arguments.map do |argument|
    if argument.is_a?(Redis::Wrap)
      argument.key
    else
      argument
    end
  end

  redis.send(command, key, *arguments, &block)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/redis/wrap.rb', line 7

def key
  @key
end

Instance Method Details

#redisObject



25
26
27
# File 'lib/redis/wrap.rb', line 25

def redis
  Redis.current
end