Class: ActiveStorageValidations::ASVAttachableAdapter::HashIo
- Inherits:
-
Base
- Object
- Base
- ActiveStorageValidations::ASVAttachableAdapter::HashIo
show all
- Defined in:
- lib/active_storage_validations/asv_attachable_adapter.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#content_type ⇒ Object
151
152
153
|
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 151
def content_type
@attachable[:content_type]
end
|
#filename ⇒ Object
155
156
157
|
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 155
def filename
@attachable[:filename]
end
|
#read(max_byte_size: nil) ⇒ Object
159
160
161
|
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 159
def read(max_byte_size: nil)
read_from(@attachable[:io], max_byte_size)
end
|
#rewind ⇒ Object
163
164
165
|
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 163
def rewind
@attachable[:io].rewind
end
|
167
168
169
170
171
172
173
174
|
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 167
def with_media_path(tempfile, &block)
io = @attachable[:io]
if io.is_a?(StringIO)
copy_to_tempfile(tempfile, io, &block)
else
File.open(io) { |file| yield file.path }
end
end
|