Module: DataGenerator::DataStorage

Defined in:
lib/howitzer/utils/data_generator/data_storage.rb

Overview

Data can be stored in memory using DataStorage

Constant Summary collapse

SPECIAL_NS_LIST =
['sauce']

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.dataObject (readonly)

Returns the value of attribute data


13
14
15
# File 'lib/howitzer/utils/data_generator/data_storage.rb', line 13

def data
  @data
end

Class Method Details

.clear_all_ns(exception_list = SPECIAL_NS_LIST) ⇒ Object

Deletes all namespaces with data

Parameters:

  • exception_list - Array of special namespaces for excluding


64
65
66
# File 'lib/howitzer/utils/data_generator/data_storage.rb', line 64

def clear_all_ns(exception_list=SPECIAL_NS_LIST)
  (@data.keys - exception_list).each {|ns| clear_ns(ns) }
end

.clear_ns(ns) ⇒ Object

Deletes all records from namespace

Parameters:

  • ns - Namespace


52
53
54
# File 'lib/howitzer/utils/data_generator/data_storage.rb', line 52

def clear_ns(ns)
  init_ns(ns)
end

.extract(ns, key = nil) ⇒ Object

Gets data from memory. Can get all namespace or single data value in namespace using key

Parameters:

  • ns - Namespace

  • key - Key that isn't necessary required (default to: nil)


39
40
41
42
# File 'lib/howitzer/utils/data_generator/data_storage.rb', line 39

def extract(ns, key=nil)
  check_ns(ns)
  key ? @data[ns][key] : @data[ns]
end

.store(ns, key, value) ⇒ Object


25
26
27
28
# File 'lib/howitzer/utils/data_generator/data_storage.rb', line 25

def store(ns, key, value)
  check_ns(ns)
  @data[ns][key] = value
end