Attachment processors allow you to modify attached files when they are attached in any way you are able. Attachment itself uses command-line programs for its included Thumbnail processor, but custom processors are not required to follow suit.
Processors are required to be defined inside the Attachment module and are also required to be a subclass of Attachment::Processor. There are only two methods you must implement to properly be a subclass: initialize and make. Initialize‘s arguments are the file that will be operated on (which is an instance of File), and a hash of options that were defined in has_attached_file‘s style hash.
All make needs to do is return an instance of File (Tempfile is acceptable) which contains the results of the processing.
See Attachment.run for more information about using command-line utilities from within Processors.
| [RW] | file | |
| [RW] | options |
[ show source ]
# File lib/data_base/attachment/processor.rb, line 31
31: def self.make(file, options = {})
32: new(file, options).make
33: end
[ show source ]
# File lib/data_base/attachment/processor.rb, line 23
23: def initialize(file, options = {})
24: @file = file
25: @options = options
26: end
[ show source ]
# File lib/data_base/attachment/processor.rb, line 28
28: def make
29: end