Sha256: 23ea802777c231e9deb0ff991f6d8ed32c6d8dc27cf0cbc14c90455bd0ad91c5
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
module RedmineCrm module Liquid class AttachmentDrop < ::Liquid::Drop delegate :id, :filename, :title, :description, :filesize, :content_type, :digest, :downloads, :created_on, :token, :visible?, :image?, :thumbnailable?, :is_text?, :readable?, to: :@attachment delegate :id, :filename, :filesize, :description, to: :@attachment def initialize(attachment) @attachment = attachment end 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 def link link_to((@attachment.description.blank? ? @attachment.filename : @attachment.description), url) end def author @author ||= UsersDrop.new @attachment.author end 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems