Class: Redmineup::Liquid::AttachmentDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Redmineup::Liquid::AttachmentDrop
- Defined in:
- lib/redmineup/liquid/drops/attachment_drop.rb
Instance Method Summary collapse
- #author ⇒ Object
-
#initialize(attachment) ⇒ AttachmentDrop
constructor
A new instance of AttachmentDrop.
- #link ⇒ Object
- #read ⇒ Object
- #url(options = {}) ⇒ Object
Constructor Details
#initialize(attachment) ⇒ AttachmentDrop
Returns a new instance of AttachmentDrop.
21 22 23 |
# File 'lib/redmineup/liquid/drops/attachment_drop.rb', line 21 def initialize() @attachment = end |
Instance Method Details
#author ⇒ Object
35 36 37 |
# File 'lib/redmineup/liquid/drops/attachment_drop.rb', line 35 def @author ||= UserDrop.new @attachment. end |
#link ⇒ Object
31 32 33 |
# File 'lib/redmineup/liquid/drops/attachment_drop.rb', line 31 def link link_to((@attachment.description.blank? ? @attachment.filename : @attachment.description), url) end |
#read ⇒ Object
39 40 41 42 43 44 |
# File 'lib/redmineup/liquid/drops/attachment_drop.rb', line 39 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 = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/redmineup/liquid/drops/attachment_drop.rb', line 25 def url( = {}) Rails.application.routes.url_helpers.(@attachment, { filename: filename, host: Setting.host_name, protocol: Setting.protocol }.merge()) end |