Class: Eluvia::File

Inherits:
Object show all
Includes:
ActiveModel::Model, ActiveModel::Attributes, AttachmentHelper
Defined in:
lib/eluvia/models/file.rb

Constant Summary

Constants included from ActiveModel::Attributes

ActiveModel::Attributes::COMPLEX_TYPES, ActiveModel::Attributes::SIMPLE_TYPES

Class Method Summary collapse

Methods included from AttachmentHelper

#attachment_url

Methods included from ActiveModel::Attributes

#initialize, #new_record?, #read_attribute, #write_attribute

Class Method Details

.from_active_storage_attachment(attachment, **options) ⇒ Object


Constructor from attachment




34
35
36
37
38
39
40
41
# File 'lib/eluvia/models/file.rb', line 34

def self.from_active_storage_attachment(attachment, **options)
  new(
    type: attachment.content_type,
    url: attachment_url(attachment, **options),
    filename: attachment.filename,
    size: attachment.byte_size
  )
end