class RedmineCrm::Liquid::AttachmentDrop
Public Class Methods
new(attachment)
click to toggle source
# File lib/redmine_crm/liquid/drops/attachment_drop.rb, line 23 def initialize(attachment) @attachment = attachment end
Public Instance Methods
link()
click to toggle source
# File lib/redmine_crm/liquid/drops/attachment_drop.rb, line 33 def link link_to((@attachment.description.blank? ? @attachment.filename : @attachment.description), url) end
read()
click to toggle source
# File lib/redmine_crm/liquid/drops/attachment_drop.rb, line 41 def read @content ||= if @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte File.new(@attachment.diskfile, "rb").read end @content end
url(options = {})
click to toggle source
# File lib/redmine_crm/liquid/drops/attachment_drop.rb, line 27 def url(options = {}) Rails.application.routes.url_helpers.download_named_attachment_url(@attachment, { filename: filename, host: Setting.host_name, protocol: Setting.protocol }.merge(options)) end