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.



23
24
25
# File 'lib/datastore.rb', line 23

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.



42
43
44
# File 'lib/datastore.rb', line 42

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)


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

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



37
38
39
# File 'lib/datastore.rb', line 37

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