Class: DCell::Registry::MongodbAdapter::Proxy
- Inherits:
-
Object
- Object
- DCell::Registry::MongodbAdapter::Proxy
- Defined in:
- lib/dcell/registries/mongodb_adapter.rb
Class Method Summary collapse
- .all(storage) ⇒ Object
- .clear_all(storage) ⇒ Object
- .get(storage, key) ⇒ Object
- .remove(storage, key) ⇒ Object
- .set(storage, key, value) ⇒ Object
Class Method Details
.all(storage) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/dcell/registries/mongodb_adapter.rb', line 51 def all(storage) keys = [] storage.each do |entry| keys << entry.key end keys end |
.clear_all(storage) ⇒ Object
66 67 68 |
# File 'lib/dcell/registries/mongodb_adapter.rb', line 66 def clear_all(storage) storage.delete_all end |
.get(storage, key) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/dcell/registries/mongodb_adapter.rb', line 43 def get(storage, key) first = storage.where(key: key).first if first and first.value return first.value['v'] end nil end |
.remove(storage, key) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/dcell/registries/mongodb_adapter.rb', line 59 def remove(storage, key) begin storage.where(key: key).delete rescue end end |
.set(storage, key, value) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/dcell/registries/mongodb_adapter.rb', line 36 def set(storage, key, value) entry = storage.find_or_create_by(key: key) entry.value = {'v' => value} entry.save! value end |