Class: Valkyrie::Storage::Disk::LazyFile
- Inherits:
-
Object
- Object
- Valkyrie::Storage::Disk::LazyFile
- Defined in:
- lib/valkyrie/storage/disk.rb
Overview
LazyFile takes File.open parameters but doesn’t leave a file handle open on instantiation. This way StorageAdapter#find_by doesn’t open a handle silently and never clean up after itself.
Class Method Summary collapse
Instance Method Summary collapse
- #_inner_file ⇒ Object
-
#initialize(path, mode) ⇒ LazyFile
constructor
A new instance of LazyFile.
Constructor Details
#initialize(path, mode) ⇒ LazyFile
Returns a new instance of LazyFile.
63 64 65 66 |
# File 'lib/valkyrie/storage/disk.rb', line 63 def initialize(path, mode) @__path = path @__mode = mode end |
Class Method Details
.open(path, mode) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/valkyrie/storage/disk.rb', line 54 def self.open(path, mode) # Open the file regularly and close it, so it can error if it doesn't # exist. File.open(path, mode).close new(path, mode) end |
Instance Method Details
#_inner_file ⇒ Object
68 69 70 |
# File 'lib/valkyrie/storage/disk.rb', line 68 def _inner_file @_inner_file ||= File.open(@__path, @__mode) end |