Class: Tzispa::Data::AdapterPool
- Inherits:
-
Object
- Object
- Tzispa::Data::AdapterPool
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/tzispa/data/adapter.rb,
lib/tzispa/data/adapter_pool.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
Instance Method Summary collapse
- #[](name = nil) ⇒ Object
-
#initialize(config, default = nil) ⇒ AdapterPool
constructor
A new instance of AdapterPool.
Constructor Details
#initialize(config, default = nil) ⇒ AdapterPool
Returns a new instance of AdapterPool.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tzispa/data/adapter.rb', line 15 def initialize(config, default=nil) Sequel.default_timezone = :utc Sequel.datetime_class = DateTime Sequel.extension :core_extensions @default = default || config.first[0].to_sym @pool = Hash.new.tap { |hpool| config.each { |key, value| conn = Sequel.connect value.adapter, :pool_class => Sequel::ThreadedConnectionPool if value.connection_validation conn.extension(:connection_validator) conn.pool.connection_validation_timeout = value.connection_validation_timeout end hpool[key.to_sym] = conn } } end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
13 14 15 |
# File 'lib/tzispa/data/adapter.rb', line 13 def default @default end |
Instance Method Details
#[](name = nil) ⇒ Object
32 33 34 |
# File 'lib/tzispa/data/adapter.rb', line 32 def [](name=nil) @pool[name&.to_sym || default] end |