Class: DevSuite::Utils::Store::Driver::Memory
- Inherits:
-
Base
- Object
- Construct::Component::Base
- Base
- DevSuite::Utils::Store::Driver::Memory
- Defined in:
- lib/dev_suite/utils/store/driver/memory.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #export(destination) ⇒ Object
- #fetch(key) ⇒ Object
- #import(source) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #set(key, value) ⇒ Object
Methods inherited from Construct::Component::Base
Constructor Details
#initialize ⇒ Memory
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
#clear ⇒ Object
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
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 |