Class: Zeng::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/zeng/connector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, conf) ⇒ Connector

Returns a new instance of Connector.



20
21
22
23
24
# File 'lib/zeng/connector.rb', line 20

def initialize(adapter, conf)
  @adapter = adapter
  self.class.config(adapter)
  establish(conf)
end

Class Method Details

.config(adapter) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/zeng/connector.rb', line 4

def self.config(adapter)
  case adapter.to_sym
  when :TC
    require 'zeng/adapters/tokyo_cabinet'
    include Adapter::TokyoCabinet
  when :TT
    require 'zeng/adapters/tokyo_tyrant'
    include Adapter::TokyoTyrant
  when :LC
    require 'zeng/adapters/light_cloud'
    include Adapter::TokyoCloud
  else
    raise ConfigError,'没有指定数据库类型!'
  end
end