Class: Trocla::Stores::Vault
- Inherits:
-
Trocla::Store
- Object
- Trocla::Store
- Trocla::Stores::Vault
- Defined in:
- lib/trocla/stores/vault.rb
Overview
the default vault based store
Instance Attribute Summary collapse
-
#destroy ⇒ Object
readonly
Returns the value of attribute destroy.
-
#mount ⇒ Object
readonly
Returns the value of attribute mount.
-
#vault ⇒ Object
readonly
Returns the value of attribute vault.
Attributes inherited from Trocla::Store
Instance Method Summary collapse
- #close ⇒ Object
- #formats(key) ⇒ Object
- #get(key, format) ⇒ Object
-
#initialize(config, trocla) ⇒ Vault
constructor
A new instance of Vault.
- #search(key) ⇒ Object
Methods inherited from Trocla::Store
Constructor Details
#initialize(config, trocla) ⇒ Vault
Returns a new instance of Vault.
5 6 7 8 9 10 11 12 |
# File 'lib/trocla/stores/vault.rb', line 5 def initialize(config, trocla) super(config, trocla) require 'vault' @mount = (config.delete(:mount) || 'kv') @destroy = (config.delete(:destroy) || false) # load expire support by default @vault = Vault::Client.new(config) end |
Instance Attribute Details
#destroy ⇒ Object (readonly)
Returns the value of attribute destroy.
3 4 5 |
# File 'lib/trocla/stores/vault.rb', line 3 def destroy @destroy end |
#mount ⇒ Object (readonly)
Returns the value of attribute mount.
3 4 5 |
# File 'lib/trocla/stores/vault.rb', line 3 def mount @mount end |
#vault ⇒ Object (readonly)
Returns the value of attribute vault.
3 4 5 |
# File 'lib/trocla/stores/vault.rb', line 3 def vault @vault end |
Instance Method Details
#close ⇒ Object
14 |
# File 'lib/trocla/stores/vault.rb', line 14 def close; end |
#formats(key) ⇒ Object
20 21 22 |
# File 'lib/trocla/stores/vault.rb', line 20 def formats(key) read(key).keys end |
#get(key, format) ⇒ Object
16 17 18 |
# File 'lib/trocla/stores/vault.rb', line 16 def get(key, format) read(key)[format.to_sym] end |
#search(key) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trocla/stores/vault.rb', line 24 def search(key) arr = key.split('/') regexp = Regexp.new(arr.pop(1)[0].to_s) path = arr.join('/') list = vault.kv(mount).list(path) list.map! do |l| if regexp.match(l) path.empty? ? l : [path, l].join('/') end end list.compact end |