Class: Triglav::Agent::Status
- Inherits:
-
Object
- Object
- Triglav::Agent::Status
- Defined in:
- lib/triglav/agent/status.rb
Constant Summary
- VERSION =
:v1
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#resource_uri ⇒ Object
readonly
Returns the value of attribute resource_uri.
-
#resource_uri_prefix ⇒ Object
readonly
Returns the value of attribute resource_uri_prefix.
Class Method Summary collapse
- .select_resource_uri_prefixes!(resource_uri_prefixes) ⇒ Object
- .select_resource_uris!(resource_uri_prefix, resource_uris) ⇒ Object
Instance Method Summary collapse
-
#get(*args) ⇒ Object
get(key) get(key1, key2) get() get([key1, key2]).
-
#getsetnx(*args) ⇒ Object
getsetnx(val) getsetnx(key, val) getsetnx(key1, key2, val) getsetnx(, val) getsetnx([key1, key2], val).
-
#initialize(resource_uri_prefix, resource_uri) ⇒ Status
constructor
A new instance of Status.
-
#merge!(*args) ⇒ Object
Merge Hash value with existing Hash value.
-
#set(*args) ⇒ Object
set(val) set(key, val) set(key1, key2, val) set(, val) set([key1, key2], val).
-
#setnx(*args) ⇒ Object
setnx(val) setnx(key, val) setnx(key1, key2, val) setnx(, val) setnx([key1, key2], val).
Constructor Details
#initialize(resource_uri_prefix, resource_uri) ⇒ Status
Returns a new instance of Status
11 12 13 14 15 16 |
# File 'lib/triglav/agent/status.rb', line 11 def initialize(resource_uri_prefix, resource_uri) @path = $setting.status_file @resource_uri_prefix = resource_uri_prefix.to_sym @resource_uri = resource_uri.to_sym @parents = [VERSION, @resource_uri_prefix, @resource_uri] end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
6 7 8 |
# File 'lib/triglav/agent/status.rb', line 6 def path @path end |
#resource_uri ⇒ Object (readonly)
Returns the value of attribute resource_uri
7 8 9 |
# File 'lib/triglav/agent/status.rb', line 7 def resource_uri @resource_uri end |
#resource_uri_prefix ⇒ Object (readonly)
Returns the value of attribute resource_uri_prefix
7 8 9 |
# File 'lib/triglav/agent/status.rb', line 7 def resource_uri_prefix @resource_uri_prefix end |
Class Method Details
.select_resource_uri_prefixes!(resource_uri_prefixes) ⇒ Object
73 74 75 |
# File 'lib/triglav/agent/status.rb', line 73 def self.select_resource_uri_prefixes!(resource_uri_prefixes) Triglav::Agent::StorageFile.select!($setting.status_file, [VERSION], resource_uri_prefixes.map(&:to_sym)) end |
.select_resource_uris!(resource_uri_prefix, resource_uris) ⇒ Object
77 78 79 |
# File 'lib/triglav/agent/status.rb', line 77 def self.select_resource_uris!(resource_uri_prefix, resource_uris) Triglav::Agent::StorageFile.select!($setting.status_file, [VERSION, resource_uri_prefix.to_sym], resource_uris.map(&:to_sym)) end |
Instance Method Details
#get(*args) ⇒ Object
get(key) get(key1, key2) get() get([key1, key2])
68 69 70 71 |
# File 'lib/triglav/agent/status.rb', line 68 def get(*args) keys = (args || []).flatten StorageFile.get(path, [*@parents, *keys]) end |
#getsetnx(*args) ⇒ Object
getsetnx(val) getsetnx(key, val) getsetnx(key1, key2, val) getsetnx(, val) getsetnx([key1, key2], val)
58 59 60 61 62 |
# File 'lib/triglav/agent/status.rb', line 58 def getsetnx(*args) val = args.pop keys = args.flatten StorageFile.getsetnx(path, [*@parents, *keys], val) end |
#merge!(*args) ⇒ Object
Merge Hash value with existing Hash value.
merge!(val) merge!(key, val) merge!(key1, key2, val) merge!(, val) merge!([key1, key2], val)
36 37 38 39 40 |
# File 'lib/triglav/agent/status.rb', line 36 def merge!(*args) val = args.pop keys = args.flatten StorageFile.merge!(path, [*@parents, *keys], val) end |
#set(*args) ⇒ Object
set(val) set(key, val) set(key1, key2, val) set(, val) set([key1, key2], val)
23 24 25 26 27 |
# File 'lib/triglav/agent/status.rb', line 23 def set(*args) val = args.pop keys = args.flatten StorageFile.set(path, [*@parents, *keys], val) end |
#setnx(*args) ⇒ Object
setnx(val) setnx(key, val) setnx(key1, key2, val) setnx(, val) setnx([key1, key2], val)
47 48 49 50 51 |
# File 'lib/triglav/agent/status.rb', line 47 def setnx(*args) val = args.pop keys = args.flatten StorageFile.setnx(path, [*@parents, *keys], val) end |