Skip to Content Skip to Search
Methods
A
C
D
F
I
M
P
S

Instance Public methods

as_json(options = {})

# File app/models/db/content_file.rb, line 73
def as_json(options = {})
  super.as_json(options).merge({
    "plan_names" => plan_names.sort,
    "plan_ids" => plan_ids.sort,
    "attachment_url" => attachment_url,
    "content_type" => content_type,
    "download_url" => attachment ? download_url : nil,
    "content_link" => content_link
  })
end

audio?()

# File app/models/db/content_file.rb, line 57
def audio?
  mime_type.include? "audio/"
end

content_type()

# File app/models/db/content_file.rb, line 61
def content_type
  if image?
    "image"
  elsif audio?
    "audio"
  elsif pdf?
    "pdf"
  else
    "file"
  end
end

document?()

# File app/models/db/content_file.rb, line 43
def document?
  %w[msword document].any? { |type| mime_type.include? type }
end

file=(input)

# File app/models/db/content_file.rb, line 21
def file=(input)
  self.attachment = if input.is_a?(Hash)
    attachment_from_direct_upload(input)
  else
    input
  end

  self.file_name = metadata_filename
end

filename()

# File app/models/db/content_file.rb, line 31
def filename
  file_name || metadata_filename
end

image?()

# File app/models/db/content_file.rb, line 39
def image?
  mime_type.include? "image/"
end

mime_type()

# File app/models/db/content_file.rb, line 84
def mime_type
  attachment ? attachment.metadata["mime_type"] : ""
end

pdf?()

# File app/models/db/content_file.rb, line 35
def pdf?
  mime_type.include? "pdf"
end

powerpoint?()

# File app/models/db/content_file.rb, line 47
def powerpoint?
  mime_type.include? "powerpoint"
end

spreadsheet?()

# File app/models/db/content_file.rb, line 51
def spreadsheet?
  types = %w[excel spreadsheet]
  filename = attachment.metadata["filename"]
  types.any? { |type| mime_type.include? type } || filename.end_with?(".csv")
end