Class: Requeus::Adapter::Filesystem
- Inherits:
-
Object
- Object
- Requeus::Adapter::Filesystem
- Defined in:
- lib/requeus/adapter/filesystem.rb
Direct Known Subclasses
Instance Method Summary collapse
- #delete(uid) ⇒ Object
- #get(uid) ⇒ Object
-
#initialize(opts) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #put(file) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Filesystem
Returns a new instance of Filesystem.
6 7 8 9 |
# File 'lib/requeus/adapter/filesystem.rb', line 6 def initialize opts @path = opts['path'] ensure_path end |
Instance Method Details
#delete(uid) ⇒ Object
23 24 25 26 |
# File 'lib/requeus/adapter/filesystem.rb', line 23 def delete uid FileUtils.remove path_for(uid) true end |
#get(uid) ⇒ Object
18 19 20 21 |
# File 'lib/requeus/adapter/filesystem.rb', line 18 def get uid return nil unless File.exists?(path_for(uid)) File.new path_for(uid) end |
#put(file) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/requeus/adapter/filesystem.rb', line 11 def put file uid = generate_id FileUtils.copy file.path, path_for(uid) FileUtils.chmod 0666, path_for(uid) uid end |