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
61 62 63 |
# File 'lib/blobby/abstract_store.rb', line 61 def delete !@hash.delete(key).nil? end |
#exists? ⇒ Boolean
Check for existence.
28 29 30 |
# File 'lib/blobby/abstract_store.rb', line 28 def exists? false end |
#read ⇒ String? #read {|chunk| ... } ⇒ void
40 41 42 43 44 45 46 47 48 |
# File 'lib/blobby/abstract_store.rb', line 40 def read content = @hash[key] if block_given? yield content nil else content end end |
#write(content) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/blobby/abstract_store.rb', line 50 def write(content) if content.respond_to?(:read) content = content.read else content = content.to_str.dup end content = content.force_encoding("BINARY") if content.respond_to?(:force_encoding) @hash[key] = content nil end |