lib/heliodor/db.rb in heliodor-0.1.0 vs lib/heliodor/db.rb in heliodor-0.1.1
- old
+ new
@@ -41,9 +41,24 @@
else
Heliodor::Query.new(self, table, @dat)
end
end
+ # Deletes given table
+ # @param table [String]
+ # @return [self]
+ def delete(table)
+ if @tsafe
+ @mutex.synchronize do
+ @dat.delete(table)
+ write(dat)
+ end
+ else
+ write(dat)
+ @dat.delete(table)
+ end
+ end
+
# Returns array of table names
# @return [Array<String>] Array of table names
def tables
Hash.from_bson(BSON::ByteBuffer.new(File.read(@file))).keys
end