Class: Cache::Client::KeyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cache-client/key_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ KeyBuilder

Returns a new instance of KeyBuilder.



5
6
7
# File 'lib/cache-client/key_builder.rb', line 5

def initialize(key)
  @key = key
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
16
# File 'lib/cache-client/key_builder.rb', line 9

def to_s
  return @key.to_cache_key if @key.respond_to?(:to_cache_key)

  return @key if @key.kind_of?(String)
  return @key.to_s if @key.kind_of?(Numeric)

  return Digest::SHA1.hexdigest(Marshal.dump(@key))
end