Class: Useless::FS
- Inherits:
-
Object
- Object
- Useless::FS
- Defined in:
- lib/useless/fs.rb
Overview
Useless::FS is a minimal wrapper around Mongo::Grid.
Defined Under Namespace
Classes: FileNotFound
Class Method Summary collapse
Instance Method Summary collapse
- #get(id) ⇒ Object
-
#initialize(mongo) ⇒ FS
constructor
A new instance of FS.
- #put(file, opts = {}) ⇒ Object
Constructor Details
#initialize(mongo) ⇒ FS
Returns a new instance of FS.
12 13 14 |
# File 'lib/useless/fs.rb', line 12 def initialize(mongo) @mongo = mongo end |
Class Method Details
Instance Method Details
#get(id) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/useless/fs.rb', line 22 def get(id) @mongo.grid.get(id) # To preserve the abstraction, raise our own exception when a file isn't # found rescue ::Mongo::GridFileNotFound => e raise FileNotFound, e. end |
#put(file, opts = {}) ⇒ Object
16 17 18 |
# File 'lib/useless/fs.rb', line 16 def put(file, opts = {}) @mongo.grid.put(file, opts) end |