Class: CarrierWave::Storage::GridFS::File
- Inherits:
-
Object
- Object
- CarrierWave::Storage::GridFS::File
- Defined in:
- lib/carrierwave/storage/grid_fs.rb
Class Attribute Summary collapse
-
.grid ⇒ Object
Returns the value of attribute grid.
Instance Attribute Summary collapse
-
#grid_file(&block) ⇒ Object
readonly
Returns the value of attribute grid_file.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#uploader ⇒ Object
readonly
Returns the value of attribute uploader.
Instance Method Summary collapse
-
#initialize(uploader, path) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #url ⇒ Object
- #write(file) ⇒ Object
Constructor Details
#initialize(uploader, path) ⇒ File
Returns a new instance of File.
28 29 30 31 32 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 28 def initialize(uploader, path) @path = path @uploader = uploader @grid_file = nil end |
Class Attribute Details
.grid ⇒ Object
Returns the value of attribute grid.
70 71 72 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 70 def grid @grid end |
Instance Attribute Details
#grid_file(&block) ⇒ Object (readonly)
Returns the value of attribute grid_file.
26 27 28 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 26 def grid_file @grid_file end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
24 25 26 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 24 def path @path end |
#uploader ⇒ Object (readonly)
Returns the value of attribute uploader.
25 26 27 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 25 def uploader @uploader end |
Instance Method Details
#read ⇒ Object
52 53 54 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 52 def read grid_file.data if grid_file end |
#url ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 34 def url unless @uploader.grid_fs_access_url nil else ::File.join(@uploader.grid_fs_access_url, path) end end |
#write(file) ⇒ Object
46 47 48 49 50 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 46 def write(file) grid[path] = file ensure @grid_file = nil end |