Class: Morlock::GemClient

Inherits:
Object
  • Object
show all
Defined in:
lib/morlock/gem_client.rb

Direct Known Subclasses

DalliGemClient, MemcacheGemClient

Constant Summary collapse

GEM_CLIENTS =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ GemClient

Returns a new instance of GemClient.



7
8
9
# File 'lib/morlock/gem_client.rb', line 7

def initialize(client)
  @client = client
end

Class Method Details

.wrap(client) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
19
# File 'lib/morlock/gem_client.rb', line 11

def self.wrap(client)
  GEM_CLIENTS.each do |gem, gem_client|
    if (eval(gem) rescue false) && client.is_a?(eval(gem))
      return gem_client.new(client)
    end
  end

  raise UnknownGemClient.new("You provided Morlock a memcached client of an unknown type: #{client.class}")
end

Instance Method Details

#delete(key) ⇒ Object



21
22
23
# File 'lib/morlock/gem_client.rb', line 21

def delete(key)
  @client.delete(key)
end