Class: Blobby::AbstractStore::StoredObject Abstract
- Inherits:
-
Object
- Object
- Blobby::AbstractStore::StoredObject
- Defined in:
- lib/blobby/abstract_store.rb
Overview
This class is abstract.
A handle to an object in the BLOB-store.
Instance Method Summary collapse
- #delete ⇒ Object
-
#exists? ⇒ Boolean
Check for existence.
- #read ⇒ Object
- #write(content) ⇒ Object
Instance Method Details
#delete ⇒ Object
63 64 65 |
# File 'lib/blobby/abstract_store.rb', line 63 def delete !@hash.delete(key).nil? end |
#exists? ⇒ Boolean
Check for existence.
30 31 32 |
# File 'lib/blobby/abstract_store.rb', line 30 def exists? false end |
#read ⇒ String? #read {|chunk| ... } ⇒ void
42 43 44 45 46 47 48 49 50 |
# File 'lib/blobby/abstract_store.rb', line 42 def read content = @hash[key] if block_given? yield content nil else content end end |
#write(content) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/blobby/abstract_store.rb', line 52 def write(content) content = if content.respond_to?(:read) content.read else content.to_str.dup end content = content.force_encoding("BINARY") if content.respond_to?(:force_encoding) @hash[key] = content nil end |