Class: ActiveStorageValidations::ASVAttachableAdapter::FileLike

Inherits:
Base
  • Object
show all
Defined in:
lib/active_storage_validations/asv_attachable_adapter.rb

Direct Known Subclasses

Path

Instance Method Summary collapse

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_typeObject



183
184
185
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 183

def content_type
  marcel_content_type
end

#filenameObject



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

#rewindObject



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

Yields:

  • (@attachable.path)


199
200
201
# File 'lib/active_storage_validations/asv_attachable_adapter.rb', line 199

def with_media_path(_tempfile)
  yield @attachable.path
end