Class: Gauge::DataStore

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

Instance Method Summary collapse

Constructor Details

#initializeDataStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DataStore.



11
12
13
# File 'lib/datastore.rb', line 11

def initialize
  clear
end

Instance Method Details

#clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/datastore.rb', line 30

def clear
  @data_map = Hash.new
end

#get(key) ⇒ object

Fetches the object corresponding to the given key

Parameters:

  • key (string)

    , the key for retrieving object.

Returns:

  • (object)


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

def get(key)
  @data_map[key]
end

#put(key, value) ⇒ Object

Stores the object against the given key

Parameters:

  • key (string)

    , the key for storing the object, has to be unique

  • value (object)

    , the object to be persisted



25
26
27
# File 'lib/datastore.rb', line 25

def put(key, value)
  @data_map[key] = value
end