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

author() click to toggle source
# File lib/redmine_crm/liquid/drops/attachment_drop.rb, line 37
def author
  @author ||= UsersDrop.new @attachment.author
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