Class: MemoryPersister
- Inherits:
-
Object
- Object
- MemoryPersister
- Defined in:
- lib/persisters/memory_persister.rb
Defined Under Namespace
Classes: Full, MemoryContainer
Instance Method Summary collapse
- #absorb(instance) ⇒ Object
-
#initialize(klass_list, options = {}) ⇒ MemoryPersister
constructor
A new instance of MemoryPersister.
Constructor Details
#initialize(klass_list, options = {}) ⇒ MemoryPersister
Returns a new instance of MemoryPersister.
5 6 7 8 9 10 |
# File 'lib/persisters/memory_persister.rb', line 5 def initialize(klass_list, = {}) klass_list.each{ |klass| make_index_getters(klass) } sub_capacity = ([:capacity] || 100000) / 2 @new_container = MemoryContainer.new klass_list, capacity: sub_capacity @old_container = MemoryContainer.new klass_list, capacity: sub_capacity end |
Instance Method Details
#absorb(instance) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/persisters/memory_persister.rb', line 12 def absorb(instance) @new_container.absorb instance rescue MemoryPersister::Full rotate_containers absorb instance end |