Class: ActiveStorageValidations::ASVAttachableAdapter::FileLike
- Defined in:
- lib/active_storage_validations/asv_attachable_adapter.rb
Direct Known Subclasses
Instance Method Summary collapse
- #content_type ⇒ Object
- #filename ⇒ Object
-
#initialize(attachable, file_supported:) ⇒ FileLike
constructor
A new instance of FileLike.
- #read(max_byte_size: nil) ⇒ Object
- #rewind ⇒ Object
- #with_media_path(_tempfile) {|@attachable.path| ... } ⇒ Object
Constructor Details
#initialize(attachable, file_supported:) ⇒ FileLike
Returns a new instance of FileLike.
178 179 180 181 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 178 def initialize(attachable, file_supported:) super raise_unsupported unless file_supported end |
Instance Method Details
#content_type ⇒ Object
183 184 185 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 183 def content_type marcel_content_type end |
#filename ⇒ Object
187 188 189 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 187 def filename File.basename(@attachable) end |
#read(max_byte_size: nil) ⇒ Object
191 192 193 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 191 def read(max_byte_size: nil) read_from(@attachable, max_byte_size) end |
#rewind ⇒ Object
195 196 197 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 195 def rewind @attachable.rewind end |
#with_media_path(_tempfile) {|@attachable.path| ... } ⇒ Object
199 200 201 |
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 199 def with_media_path(_tempfile) yield @attachable.path end |