Class: Blobby::CompositeStore::StoredObject
- Inherits:
-
Object
- Object
- Blobby::CompositeStore::StoredObject
- Defined in:
- lib/blobby/composite_store.rb
Overview
Represents an object in the store.
Instance Method Summary collapse
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(objects) ⇒ StoredObject
constructor
A new instance of StoredObject.
- #read(&block) ⇒ Object
- #write(content) ⇒ Object
Constructor Details
#initialize(objects) ⇒ StoredObject
Returns a new instance of StoredObject.
32 33 34 |
# File 'lib/blobby/composite_store.rb', line 32 def initialize(objects) @objects = objects end |
Instance Method Details
#delete ⇒ Object
55 56 57 |
# File 'lib/blobby/composite_store.rb', line 55 def delete objects.all?(&:delete) end |
#exists? ⇒ Boolean
36 37 38 |
# File 'lib/blobby/composite_store.rb', line 36 def exists? objects.any?(&:exists?) end |
#read(&block) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/blobby/composite_store.rb', line 40 def read(&block) objects.each do |o| return o.read(&block) if o.exists? end nil end |
#write(content) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/blobby/composite_store.rb', line 47 def write(content) content = content.read if content.respond_to?(:read) objects.each do |o| o.write(content) end nil end |