Class: DataMapper::Adapters::ReaderPoolAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- DataMapper::Adapters::ReaderPoolAdapter
- Extended by:
- Forwardable
- Defined in:
- lib/data_mapper/adapters/reader_pool_adapter.rb
Instance Attribute Summary collapse
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
Instance Method Summary collapse
-
#initialize(name, options) ⇒ ReaderPoolAdapter
constructor
A new instance of ReaderPoolAdapter.
- #kind_of?(kind) ⇒ Boolean
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ ReaderPoolAdapter
Returns a new instance of ReaderPoolAdapter.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/data_mapper/adapters/reader_pool_adapter.rb', line 13 def initialize(name, ) super assert_kind_of 'options', @options[:pool], Array raise ArgumentError, "The are no adapters in the adapter pool" if @options[:pool].empty? @pool = [] @options[:pool].each do || adapter = if .kind_of?(AbstractAdapter) else assert_kind_of 'pool_adapter_options', , Hash Adapters.new(name, ) end @pool.push(adapter) end @number_generator = Random.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
35 36 37 |
# File 'lib/data_mapper/adapters/reader_pool_adapter.rb', line 35 def method_missing(meth, *args, &block) random_adapter.send(meth, *args, &block) end |
Instance Attribute Details
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
9 10 11 |
# File 'lib/data_mapper/adapters/reader_pool_adapter.rb', line 9 def pool @pool end |
Instance Method Details
#kind_of?(kind) ⇒ Boolean
39 40 41 |
# File 'lib/data_mapper/adapters/reader_pool_adapter.rb', line 39 def kind_of?(kind) super || random_adapter.kind_of?(kind) end |