Class: Kward::PluginScopedStore
- Inherits:
-
Object
- Object
- Kward::PluginScopedStore
- Defined in:
- lib/kward/plugins/host.rb
Overview
Namespaced view over an identified plugin's durable storage.
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(storage, namespace) ⇒ PluginScopedStore
constructor
A new instance of PluginScopedStore.
- #put(key, value) ⇒ Object
Constructor Details
#initialize(storage, namespace) ⇒ PluginScopedStore
Returns a new instance of PluginScopedStore.
90 91 92 93 94 95 96 |
# File 'lib/kward/plugins/host.rb', line 90 def initialize(storage, namespace) @storage = storage @namespace = namespace.to_s raise ArgumentError, "plugin storage namespace is required" if @namespace.empty? @prefix = "scope.#{Digest::SHA256.hexdigest(@namespace)[0, 24]}" end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
88 89 90 |
# File 'lib/kward/plugins/host.rb', line 88 def namespace @namespace end |
Instance Method Details
#delete(key) ⇒ Object
106 107 108 |
# File 'lib/kward/plugins/host.rb', line 106 def delete(key) @storage.delete(scoped_key(key)) end |
#get(key) ⇒ Object
98 99 100 |
# File 'lib/kward/plugins/host.rb', line 98 def get(key) @storage.get(scoped_key(key)) end |
#put(key, value) ⇒ Object
102 103 104 |
# File 'lib/kward/plugins/host.rb', line 102 def put(key, value) @storage.put(scoped_key(key), value) end |