Class: DevSuite::Utils::Store::Driver::Memory

Inherits:
Base show all
Defined in:
lib/dev_suite/utils/store/driver/memory.rb

Instance Method Summary collapse

Methods inherited from Construct::Component::Base

component_key

Constructor Details

#initializeMemory

Returns a new instance of Memory.



8
9
10
11
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 8

def initialize
  super
  @data = {}
end

Instance Method Details

#clearObject



25
26
27
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 25

def clear
  @data.clear
end

#delete(key) ⇒ Object



21
22
23
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 21

def delete(key)
  Data.delete_key_by_path(@data, key)
end

#export(destination) ⇒ Object



35
36
37
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 35

def export(destination)
  FileWriter.write(destination, @data)
end

#fetch(key) ⇒ Object



17
18
19
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 17

def fetch(key)
  Data.get_value_by_path(@data, key)
end

#import(source) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 29

def import(source)
  raise ArgumentError, "The file does not exist" unless ::File.exist?(source)

  @data = FileLoader.load(source)
end

#set(key, value) ⇒ Object



13
14
15
# File 'lib/dev_suite/utils/store/driver/memory.rb', line 13

def set(key, value)
  Data.set_value_by_path(@data, key, value)
end