Class: PageFile

Inherits:
ApplicationRecord
  • Object
show all
Includes:
PagesCore::Sweepable
Defined in:
app/models/page_file.rb

Instance Attribute Summary

Attributes included from PagesCore::Sweepable

#cache_swept

Instance Method Summary collapse

Instance Method Details

#attachmentObject



17
18
19
# File 'app/models/page_file.rb', line 17

def attachment
  super&.localize!(locale)
end

#descriptionObject



25
26
27
# File 'app/models/page_file.rb', line 25

def description
  attachment&.description
end

#filenameObject



29
30
31
# File 'app/models/page_file.rb', line 29

def filename
  attachment&.filename
end

#formatObject



37
38
39
# File 'app/models/page_file.rb', line 37

def format
  attachment&.format
end

#format?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/page_file.rb', line 33

def format?
  attachment&.format?
end

#nameObject



21
22
23
# File 'app/models/page_file.rb', line 21

def name
  attachment&.name
end

#to_paramObject



41
42
43
44
45
46
47
48
49
# File 'app/models/page_file.rb', line 41

def to_param
  return id unless attachment

  if attachment.filename_extension?
    "#{id}-#{attachment.content_hash}.#{attachment.filename_extension}"
  else
    "#{id}-#{attachment.content_hash}"
  end
end