Class: Rex::JSONHashFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/json_hash_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ JSONHashFile

Returns a new instance of JSONHashFile.



14
15
16
17
18
19
# File 'lib/rex/json_hash_file.rb', line 14

def initialize(path)
  self.path = path
  @lock = Mutex.new
  @hash = {}
  @last = 0
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/rex/json_hash_file.rb', line 12

def path
  @path
end

Instance Method Details

#[](k) ⇒ Object



21
22
23
24
# File 'lib/rex/json_hash_file.rb', line 21

def [](k)
  synced_update
  @hash[k]
end

#[]=(k, v) ⇒ Object



26
27
28
29
30
# File 'lib/rex/json_hash_file.rb', line 26

def []=(k,v)
  synced_update do
    @hash[k] = v
  end
end

#clearObject



43
44
45
46
47
# File 'lib/rex/json_hash_file.rb', line 43

def clear
  synced_update do
    @hash.clear
  end
end

#delete(k) ⇒ Object



37
38
39
40
41
# File 'lib/rex/json_hash_file.rb', line 37

def delete(k)
  synced_update do
    @hash.delete(k)
  end
end

#keysObject



32
33
34
35
# File 'lib/rex/json_hash_file.rb', line 32

def keys
  synced_update
  @hash.keys
end