Class: Alchemy::EssenceFile

Inherits:
BaseRecord
  • Object
show all
Defined in:
app/models/alchemy/essence_file.rb

Instance Method Summary collapse

Instance Method Details

#attachment_urlObject



21
22
23
24
25
26
27
28
29
# File 'app/models/alchemy/essence_file.rb', line 21

def attachment_url
  return if attachment.nil?

  routes.download_attachment_path(
    id: attachment.id,
    name: attachment.slug,
    format: attachment.suffix,
  )
end

#preview_text(max = 30) ⇒ Object



31
32
33
34
35
# File 'app/models/alchemy/essence_file.rb', line 31

def preview_text(max = 30)
  return "" if attachment.blank?

  attachment.name.to_s[0..max - 1]
end

#serialized_ingredientObject

Returns a serialized ingredient value for json api



38
39
40
# File 'app/models/alchemy/essence_file.rb', line 38

def serialized_ingredient
  attachment_url
end