Class: Blobby::CompositeStore::StoredObject

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

Overview

Represents an object in the store.

Instance Method Summary collapse

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

#deleteObject



55
56
57
# File 'lib/blobby/composite_store.rb', line 55

def delete
  objects.all?(&:delete)
end

#exists?Boolean

Returns:

  • (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