Class: DatabaseRecorder::Storage::File
- Inherits:
-
Base
- Object
- Base
- DatabaseRecorder::Storage::File
show all
- Defined in:
- lib/database_recorder/storage/file.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#load ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/database_recorder/storage/file.rb', line 6
def load
stored_data = ::File.exist?(record_file) ? ::File.read(record_file) : false
if stored_data
data = YAML.load(stored_data) @recording.cache = data['queries']
@recording.entities = data['entities']
true
else
false
end
end
|
#save ⇒ Object
18
19
20
21
22
23
|
# File 'lib/database_recorder/storage/file.rb', line 18
def save
data = { 'queries' => @recording.queries }
data['entities'] = @recording.entities if @recording.entities.any?
serialized_data = data.to_yaml
::File.write(record_file, serialized_data)
end
|