Class: Paperclip::Processor
- Inherits:
-
Object
- Object
- Paperclip::Processor
- Defined in:
- lib/paperclip/processor.rb
Overview
Paperclip processors allow you to modify attached files when they are attached in any way you are able. Paperclip 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 Paperclip module and are also required to be a subclass of Paperclip::Processor. There is only one method you must implement to properly be a subclass: #make, but #initialize may also be of use. Both methods accept 3 arguments: the file that will be operated on (which is an instance of File), a hash of options that were defined in has_attached_file's style hash, and the Paperclip::Attachment itself.
All #make needs to return is an instance of File (Tempfile is acceptable) which contains the results of the processing.
See Paperclip.run for more information about using command-line utilities from within Processors.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) attachment
Returns the value of attribute attachment.
-
- (Object) file
Returns the value of attribute file.
-
- (Object) options
Returns the value of attribute options.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Processor) initialize(file, options = {}, attachment = nil)
constructor
A new instance of Processor.
- - (Object) make
Constructor Details
- (Processor) initialize(file, options = {}, attachment = nil)
A new instance of Processor
23 24 25 26 27 |
# File 'lib/paperclip/processor.rb', line 23 def initialize file, = {}, = nil @file = file @options = @attachment = end |
Instance Attribute Details
- (Object) attachment
Returns the value of attribute attachment
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def @attachment end |
- (Object) file
Returns the value of attribute file
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def file @file end |
- (Object) options
Returns the value of attribute options
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def @options end |
Class Method Details
+ (Object) make(file, options = {}, attachment = nil)
32 33 34 |
# File 'lib/paperclip/processor.rb', line 32 def self.make file, = {}, = nil new(file, , ).make end |
Instance Method Details
- (Object) make
29 30 |
# File 'lib/paperclip/processor.rb', line 29 def make end |