Module: RuPol::ClassMethods
- Defined in:
- lib/ru_pol.rb
Instance Method Summary collapse
- #_pool ⇒ Object
- #default_pool_size ⇒ Object
- #empty_pool! ⇒ Object
- #max_pool_size(max_size) ⇒ Object
- #rehydrate(*init_opts, &block) ⇒ Object
Instance Method Details
#_pool ⇒ Object
15 16 17 |
# File 'lib/ru_pol.rb', line 15 def _pool @pool ||= Pool.new(default_pool_size, self) end |
#default_pool_size ⇒ Object
19 20 21 |
# File 'lib/ru_pol.rb', line 19 def default_pool_size superclass.respond_to?(:_pool) ? superclass._pool.max_size : 1000 end |
#empty_pool! ⇒ Object
27 28 29 |
# File 'lib/ru_pol.rb', line 27 def empty_pool! _pool.empty! end |
#max_pool_size(max_size) ⇒ Object
23 24 25 |
# File 'lib/ru_pol.rb', line 23 def max_pool_size(max_size) _pool.max_size = max_size end |
#rehydrate(*init_opts, &block) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ru_pol.rb', line 31 def rehydrate(*init_opts, &block) instance = _pool.get if instance instance.instance_eval { init_opts.empty? ? initialize(&block) : initialize(*init_opts, &block) } end instance end |