Class: Dragonfly::MemoryDataStore
- Defined in:
- lib/dragonfly/memory_data_store.rb
Instance Method Summary collapse
- #destroy(uid) ⇒ Object
-
#initialize ⇒ MemoryDataStore
constructor
A new instance of MemoryDataStore.
- #read(uid) ⇒ Object
- #write(content, opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ MemoryDataStore
Returns a new instance of MemoryDataStore.
4 5 6 |
# File 'lib/dragonfly/memory_data_store.rb', line 4 def initialize @content_store = {} end |
Instance Method Details
#destroy(uid) ⇒ Object
19 20 21 |
# File 'lib/dragonfly/memory_data_store.rb', line 19 def destroy(uid) content_store.delete(uid) end |
#read(uid) ⇒ Object
14 15 16 17 |
# File 'lib/dragonfly/memory_data_store.rb', line 14 def read(uid) data = content_store[uid] [data[:content], data[:meta]] if data end |
#write(content, opts = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/dragonfly/memory_data_store.rb', line 8 def write(content, opts={}) uid = opts[:uid] || generate_uid content_store[uid] = {:content => content.data, :meta => content..dup} uid end |