Class: Moneta::Adapters::Fog
- Inherits:
-
Base
- Object
- Base
- Moneta::Adapters::Fog
show all
- Defined in:
- lib/moneta/adapters/fog.rb
Overview
Fog backend (Cloud storage services)
Instance Method Summary
collapse
Methods inherited from Base
#[], #[]=, #close, #decrement, #fetch, #increment
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ Fog
13
14
15
16
17
|
# File 'lib/moneta/adapters/fog.rb', line 13
def initialize(options = {})
raise ArgumentError, 'Option :dir is required' unless dir = options.delete(:dir)
storage = ::Fog::Storage.new(options)
@directory = storage.directories.create(:key => dir)
end
|
Instance Method Details
#clear(options = {}) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/moneta/adapters/fog.rb', line 41
def clear(options = {})
@directory.files.all.each do |file|
file.destroy
end
self
end
|
#delete(key, options = {}) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/moneta/adapters/fog.rb', line 28
def delete(key, options = {})
if value = @directory.files.get(key)
body = value.body
value.destroy
body
end
end
|
#key?(key, options = {}) ⇒ Boolean
19
20
21
|
# File 'lib/moneta/adapters/fog.rb', line 19
def key?(key, options = {})
@directory.files.head(key) != nil
end
|
#load(key, options = {}) ⇒ Object
23
24
25
26
|
# File 'lib/moneta/adapters/fog.rb', line 23
def load(key, options = {})
value = @directory.files.get(key)
value && value.body
end
|
#store(key, value, options = {}) ⇒ Object
36
37
38
39
|
# File 'lib/moneta/adapters/fog.rb', line 36
def store(key, value, options = {})
@directory.files.create(:key => key, :body => value)
value
end
|