module PdfCover::ClassMethods::Paperclip
Public Instance Methods
pdf_cover_attachment(attachment_name, options = {})
click to toggle source
Adds a new attached file to the caller that has the pdf cover processors prepended to the list of processors given.
@param attachment_name [Symbol] the name of the new attachment. The fields described in the Paperclip
documentation for attachments are needed for this one. @param options [Hash] the same options that are accepted by Paperclip
, they are passed to the has_attached_file call with just a new processor prepended to the given ones. The PdfCover
processor will use the quality provided in the `convert_options` option when generating the jpeg.
@example A sample ActiveRecord model with a pdf_cover attachment:
class WithPaperclip < ActiveRecord::Base include PdfCover pdf_cover_attachment :pdf, styles: { pdf_cover: ['', :jpeg]}, convert_options: { all: '-quality 95 -density 300' } # Note that you must set content type validation as required by Paperclip validates_attachment_content_type :pdf, content_type: %w(application/pdf) end
# File lib/pdf_cover.rb, line 63 def pdf_cover_attachment(attachment_name, options = {}) options[:processors] = (options[:processors] || []).unshift(:pdf_cover_processor) has_attached_file attachment_name, options end