Class: Valkyrie::Persistence::BufferedPersister
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::BufferedPersister
- Defined in:
- lib/valkyrie/persistence/buffered_persister.rb
Overview
Implements the DataMapper Pattern to proxy another Metadata Persister
Provides with_buffer to send multiple updates at one time to the proxied persister
In some cases this will realize performance gains
Instance Attribute Summary collapse
-
#buffer_class ⇒ Object
readonly
Returns the value of attribute buffer_class.
-
#persister ⇒ Object
readonly
Returns the value of attribute persister.
Instance Method Summary collapse
- #delete(resource:) ⇒ Object
-
#initialize(persister, buffer_class: Valkyrie::Persistence::DeleteTrackingBuffer) ⇒ BufferedPersister
constructor
A new instance of BufferedPersister.
- #save(resource:, external_resource: false) ⇒ Object
- #save_all(resources:) ⇒ Object
- #with_buffer {|[Valkyrie::Persistence::CompositePersister.new(self, memory_buffer.persister), memory_buffer]| ... } ⇒ Object
Constructor Details
#initialize(persister, buffer_class: Valkyrie::Persistence::DeleteTrackingBuffer) ⇒ BufferedPersister
Returns a new instance of BufferedPersister.
22 23 24 25 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 22 def initialize(persister, buffer_class: Valkyrie::Persistence::DeleteTrackingBuffer) @persister = persister @buffer_class = buffer_class end |
Instance Attribute Details
#buffer_class ⇒ Object (readonly)
Returns the value of attribute buffer_class.
20 21 22 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 20 def buffer_class @buffer_class end |
#persister ⇒ Object (readonly)
Returns the value of attribute persister.
20 21 22 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 20 def persister @persister end |
Instance Method Details
#delete(resource:) ⇒ Object
35 36 37 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 35 def delete(resource:) persister.delete(resource: resource) end |
#save(resource:, external_resource: false) ⇒ Object
27 28 29 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 27 def save(resource:, external_resource: false) persister.save(resource: resource, external_resource: external_resource) end |
#save_all(resources:) ⇒ Object
31 32 33 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 31 def save_all(resources:) persister.save_all(resources: resources) end |
#with_buffer {|[Valkyrie::Persistence::CompositePersister.new(self, memory_buffer.persister), memory_buffer]| ... } ⇒ Object
39 40 41 42 |
# File 'lib/valkyrie/persistence/buffered_persister.rb', line 39 def with_buffer memory_buffer = buffer_class.new yield [Valkyrie::Persistence::CompositePersister.new(self, memory_buffer.persister), memory_buffer] end |