Class: Blobby::LoggingStore::StoredObject

Inherits:
Object
  • Object
show all
Defined in:
lib/blobby/logging_store.rb

Overview

Represents an object in the store.

Instance Method Summary collapse

Constructor Details

#initialize(object, callbacks = {}) ⇒ StoredObject

Returns a new instance of StoredObject.



36
37
38
39
40
# File 'lib/blobby/logging_store.rb', line 36

def initialize(object, callbacks = {})
  @object = object
  @on_write = callbacks[:on_write] || -> {}
  @on_delete = callbacks[:on_delete] || -> {}
end

Instance Method Details

#deleteObject



56
57
58
59
60
# File 'lib/blobby/logging_store.rb', line 56

def delete
  deleted = @object.delete
  @on_delete.call if deleted
  deleted
end

#exists?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/blobby/logging_store.rb', line 42

def exists?
  @object.exists?
end

#read(&block) ⇒ Object



46
47
48
# File 'lib/blobby/logging_store.rb', line 46

def read(&block)
  @object.read(&block)
end

#write(*args) ⇒ Object



50
51
52
53
54
# File 'lib/blobby/logging_store.rb', line 50

def write(*args)
  @object.write(*args)
  @on_write.call
  nil
end