encoding: utf-8
| VERSION | = | "2.3.8" unless defined? Paperclip::VERSION |
# File lib/paperclip.rb, line 116
116: def each_instance_with_attachment(klass, name)
117: Object.const_get(klass).all.each do |instance|
118: yield(instance) if instance.send("#{name}?""#{name}?")
119: end
120: end
# File lib/paperclip.rb, line 79
79: def interpolates key, &block
80: Paperclip::Interpolations[key] = block
81: end
Log a paperclip-specific line. Uses ActiveRecord::Base.logger by default. Set Paperclip.options[:log] to false to turn off.
# File lib/paperclip.rb, line 124
124: def log message
125: logger.info("[paperclip] #{message}") if logging?
126: end
Provides configurability to Paperclip. There are a number of options available, such as:
# File lib/paperclip.rb, line 64
64: def options
65: @options ||= {
66: :whiny => true,
67: :image_magick_path => nil,
68: :command_path => nil,
69: :log => true,
70: :log_command => true,
71: :swallow_stderr => true
72: }
73: end
The run method takes a command to execute and an array of parameters that get passed to it. The command is prefixed with the :command_path option from Paperclip.options. If you have many commands to run and they are in different paths, the suggested course of action is to symlink them so they are all in the same directory.
If the command returns with a result code that is not one of the expected_outcodes, a PaperclipCommandLineError will be raised. Generally a code of 0 is expected, but a list of codes may be passed if necessary. These codes should be passed as a hash as the last argument, like so:
Paperclip.run("echo", "something", :expected_outcodes => [0,1,2,3])
This method can log the command being run when Paperclip.options[:log_command] is set to true (defaults to false). This will only log if logging in general is set to true as well.
# File lib/paperclip.rb, line 99
99: def run cmd, *params
100: if options[:image_magick_path]
101: Paperclip.log("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead")
102: end
103: CommandLine.path = options[:command_path] || options[:image_magick_path]
104: CommandLine.new(cmd, *params).run
105: end