Class: Moneta::Adapters::Fog
- Inherits:
-
Object
- Object
- Moneta::Adapters::Fog
- Includes:
- Defaults
- Defined in:
- lib/moneta/adapters/fog.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#clear ⇒ Object
def update_key(key, options = {}) debug “update_key(key=#key, options=#optionsoptions.inspect)” k = s3_key(key, false) k.save_meta(meta_headers_from_options(options)) unless k.nil? end.
- #delete(key) ⇒ Object
-
#initialize(options = {}) ⇒ Fog
constructor
A new instance of Fog.
- #key?(key) ⇒ Boolean
- #store(key, value, options = {}) ⇒ Object
Methods included from Defaults
Constructor Details
#initialize(options = {}) ⇒ Fog
Returns a new instance of Fog.
13 14 15 16 17 |
# File 'lib/moneta/adapters/fog.rb', line 13 def initialize( = {}) bucket = .delete(:namespace) s3 = .delete(:cloud).new() @directory = s3.directories.create(:key => bucket) end |
Instance Method Details
#[](key) ⇒ Object
23 24 25 26 27 |
# File 'lib/moneta/adapters/fog.rb', line 23 def [](key) if value = get(key) deserialize(value.body) end end |
#clear ⇒ Object
def update_key(key, options = {})
debug "update_key(key=#{key}, options=#{.inspect})"
k = s3_key(key, false)
k.(()) unless k.nil?
end
49 50 51 52 53 54 |
# File 'lib/moneta/adapters/fog.rb', line 49 def clear @directory.files.all.each do |file| file.destroy end self end |
#delete(key) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/moneta/adapters/fog.rb', line 29 def delete(key) value = get(key) if value value.destroy deserialize(value.body) end end |
#key?(key) ⇒ Boolean
19 20 21 |
# File 'lib/moneta/adapters/fog.rb', line 19 def key?(key) !@directory.files.head(key_for(key)).nil? end |
#store(key, value, options = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/moneta/adapters/fog.rb', line 37 def store(key, value, = {}) #perms = options[:perms] #headers = options[:headers] || {} @directory.files.create(:key => key_for(key), :body => serialize(value)) end |