Module: Nuri::Master::Model
- Defined in:
- lib/nuri/directory.rb
Constant Summary collapse
- @@mutex =
Mutex.new
- @@model =
{}
Class Method Summary collapse
Class Method Details
.delete(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nuri/directory.rb', line 28 def self.delete(path) @@mutex.synchronize { parent_path, key = path.pop_ref if path.pop_ref if key.nil? @@model.delete(parent_path) else parent = @@model.at?(parent_path) fail "#{parent_path} is invalid! - #{parent.class.name}" if !parent.is_a?(Hash) parent.delete(key) end } end |
.get(path) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/nuri/directory.rb', line 20 def self.get(path) data = nil @@mutex.synchronize { data = @@model.at?(path) } data end |
.set(path, data) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/nuri/directory.rb', line 7 def self.set(path, data) @@mutex.synchronize { parent_path, key = path.pop_ref if key.nil? @@model[parent_path] = data else parent = @@model.at?(parent_path) fail "#{parent_path} is invalid! - #{parent.class.name}" if !parent.is_a?(Hash) parent[key] = data end } end |