Class: AppEngineUtils::Datastore::Blob
- Inherits:
-
Object
- Object
- AppEngineUtils::Datastore::Blob
- Defined in:
- lib/appengine-utils/datastore/blob.rb
Instance Method Summary collapse
Instance Method Details
#create(blob) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/appengine-utils/datastore/blob.rb', line 7 def create(blob) @blob = AppEngine::Datastore::Blob.new(blob).to_java entity = AppEngine::Datastore::Entity.new("Blob") entity['blob']=@blob key = AppEngine::Datastore.put(entity) key.to_s end |
#delete(key) ⇒ Object
35 36 37 38 39 |
# File 'lib/appengine-utils/datastore/blob.rb', line 35 def delete(key) datastore_key = AppEngine::Datastore::Key.new(key) result = AppEngine::Datastore.delete(datastore_key) result end |
#read(key) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/appengine-utils/datastore/blob.rb', line 15 def read(key) result = nil begin datastore_key = AppEngine::Datastore::Key.new(key) entity = AppEngine::Datastore.get(datastore_key) result = entity['blob'] rescue AppEngine::Datastore::EntityNotFound result = nil end result end |
#update(key, dataset) ⇒ Object
29 30 31 32 33 |
# File 'lib/appengine-utils/datastore/blob.rb', line 29 def update(key,dataset) delete(key) new_key = create(dataset) new_key end |