Class: Blobby::CompositeStore::StoredObject
- Inherits:
-
Object
- Object
- Blobby::CompositeStore::StoredObject
- Defined in:
- lib/blobby/composite_store.rb
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.
29 30 31 |
# File 'lib/blobby/composite_store.rb', line 29 def initialize(objects) @objects = objects end |
Instance Method Details
#delete ⇒ Object
52 53 54 |
# File 'lib/blobby/composite_store.rb', line 52 def delete objects.all?(&:delete) end |
#exists? ⇒ Boolean
33 34 35 |
# File 'lib/blobby/composite_store.rb', line 33 def exists? objects.any?(&:exists?) end |
#read(&block) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/blobby/composite_store.rb', line 37 def read(&block) objects.each do |o| return o.read(&block) if o.exists? end nil end |
#write(content) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/blobby/composite_store.rb', line 44 def write(content) content = content.read if content.respond_to?(:read) objects.each do |o| o.write(content) end nil end |