Class: Blobby::LoggingStore::StoredObject
- Inherits:
-
Object
- Object
- Blobby::LoggingStore::StoredObject
- Defined in:
- lib/blobby/logging_store.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(object, callbacks = {}) ⇒ StoredObject
constructor
A new instance of StoredObject.
- #read(&block) ⇒ Object
- #write(*args) ⇒ Object
Constructor Details
#initialize(object, callbacks = {}) ⇒ StoredObject
Returns a new instance of StoredObject.
33 34 35 36 37 |
# File 'lib/blobby/logging_store.rb', line 33 def initialize(object, callbacks = {}) @object = object @on_write = callbacks[:on_write] || -> {} @on_delete = callbacks[:on_delete] || -> {} end |
Instance Method Details
#delete ⇒ Object
53 54 55 56 57 |
# File 'lib/blobby/logging_store.rb', line 53 def delete deleted = @object.delete @on_delete.call if deleted deleted end |
#exists? ⇒ Boolean
39 40 41 |
# File 'lib/blobby/logging_store.rb', line 39 def exists? @object.exists? end |
#read(&block) ⇒ Object
43 44 45 |
# File 'lib/blobby/logging_store.rb', line 43 def read(&block) @object.read(&block) end |
#write(*args) ⇒ Object
47 48 49 50 51 |
# File 'lib/blobby/logging_store.rb', line 47 def write(*args) @object.write(*args) @on_write.call nil end |