Class: Rack::DevInsight::FileStore
- Inherits:
-
Object
- Object
- Rack::DevInsight::FileStore
- Defined in:
- lib/rack/dev_insight/storage/file_store.rb
Instance Method Summary collapse
-
#initialize ⇒ FileStore
constructor
A new instance of FileStore.
- #read(id) ⇒ Object
- #write(result) ⇒ Object
Constructor Details
#initialize ⇒ FileStore
Returns a new instance of FileStore.
6 7 8 9 |
# File 'lib/rack/dev_insight/storage/file_store.rb', line 6 def initialize @dir_path = DevInsight.config.file_store_dir_path @pool_size = DevInsight.config.file_store_pool_size end |
Instance Method Details
#read(id) ⇒ Object
19 20 21 22 23 |
# File 'lib/rack/dev_insight/storage/file_store.rb', line 19 def read(id) return nil unless ::File.exist?(file_path(id)) Marshal.load(::File.binread(file_path(id))) # rubocop:disable Security/MarshalLoad end |
#write(result) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/rack/dev_insight/storage/file_store.rb', line 11 def write(result) ::File.open(file_path(result.id), 'wb+') do |f| f.sync = true f.write Marshal.dump(result) end reap_excess_files end |