Class: Thumbo::Mogilefs
- Inherits:
-
AbstractStorage
- Object
- AbstractStorage
- Thumbo::Mogilefs
- Defined in:
- lib/thumbo/storages/mogilefs.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#timeout_time ⇒ Object
Returns the value of attribute timeout_time.
Instance Method Summary collapse
- #delete(filename) ⇒ Object
-
#initialize(opts = {}) ⇒ Mogilefs
constructor
A new instance of Mogilefs.
-
#paths(filename) ⇒ Object
raises MogileFS::Backend::UnknownKeyError.
- #read(filename) ⇒ Object
- #write(filename, blob) ⇒ Object
Methods inherited from AbstractStorage
Constructor Details
#initialize(opts = {}) ⇒ Mogilefs
Returns a new instance of Mogilefs.
13 14 15 16 17 18 |
# File 'lib/thumbo/storages/mogilefs.rb', line 13 def initialize opts = {} @klass = opts[:klass] || 'thumbo' @domain = opts[:domain] || 'thumbo' @hosts = opts[:hosts] || ['127.0.0.1:6001'] @timeout_time = opts[:timeout_time] || 2 end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
12 13 14 |
# File 'lib/thumbo/storages/mogilefs.rb', line 12 def client @client end |
#domain ⇒ Object
Returns the value of attribute domain.
11 12 13 |
# File 'lib/thumbo/storages/mogilefs.rb', line 11 def domain @domain end |
#hosts ⇒ Object
Returns the value of attribute hosts.
11 12 13 |
# File 'lib/thumbo/storages/mogilefs.rb', line 11 def hosts @hosts end |
#klass ⇒ Object
Returns the value of attribute klass.
11 12 13 |
# File 'lib/thumbo/storages/mogilefs.rb', line 11 def klass @klass end |
#timeout_time ⇒ Object
Returns the value of attribute timeout_time.
11 12 13 |
# File 'lib/thumbo/storages/mogilefs.rb', line 11 def timeout_time @timeout_time end |
Instance Method Details
#delete(filename) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/thumbo/storages/mogilefs.rb', line 32 def delete filename client.delete(filename) rescue MogileFS::Backend::UnknownKeyError raise_file_not_found(filename) end |
#paths(filename) ⇒ Object
raises MogileFS::Backend::UnknownKeyError
41 42 43 44 45 46 47 |
# File 'lib/thumbo/storages/mogilefs.rb', line 41 def paths filename client.get_paths(filename) rescue MogileFS::Backend::UnknownKeyError raise_file_not_found(filename) end |
#read(filename) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/thumbo/storages/mogilefs.rb', line 20 def read filename client.get_file_data(filename) rescue MogileFS::Backend::UnknownKeyError raise_file_not_found(filename) end |
#write(filename, blob) ⇒ Object
28 29 30 |
# File 'lib/thumbo/storages/mogilefs.rb', line 28 def write filename, blob client.store_content(filename, klass, blob) end |