Class: DHT::Storage

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/dht/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Storage

Returns a new instance of Storage.



9
10
11
12
# File 'lib/dht/storage.rb', line 9

def initialize(key)
  @key      = key
  @database = {}
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



7
8
9
# File 'lib/dht/storage.rb', line 7

def database
  @database
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/dht/storage.rb', line 7

def key
  @key
end

Instance Method Details

#[](key) ⇒ Object



22
23
24
# File 'lib/dht/storage.rb', line 22

def [](key)
  get(key)
end

#[]=(key, value) ⇒ Object



26
27
28
# File 'lib/dht/storage.rb', line 26

def []=(key, value)
  store(key, value)
end

#get(key) ⇒ Object



18
19
20
# File 'lib/dht/storage.rb', line 18

def get(key)
  @database[key]
end

#store(key, value) ⇒ Object



14
15
16
# File 'lib/dht/storage.rb', line 14

def store(key, value)
  @database[key] = value
end